Tuesday, March 20, 2012

Google Map Integration

Part 1: Creating a Map Activity

  1. Start a new project named HelloAndroidcodeplusMaps.
  2. Because the Maps library is not a part of the standard Android library, you must declare it in the Android Manifest. Open the AndroidManifest.xml file and add the following as a child of the <application> element:
  3.  <uses-library android:name="com.google.android.maps"/>
  4. You also need access to the Internet in order to retrieve map tiles, so you must also request the INTERNET permission. In the manifest file, add the following as a child of the <manifest> element:
    <uses-permission android:name="android.permission.INTERNET" />
  5. While you're in the manifest, give the map some more space by getting rid of the title bar with the "NoTitleBar" theme:
    <activity android:name=".HelloAndroidcodeplusMap"  
    android:label="@string/app_name"
         android:theme="@android:style/Theme.NoTitleBar">
  6. Open the res/layout/main.xml file and add a single com.google.android.maps.MapView as the root node:
    <?xml version="1.0" encoding="utf-8"?>
    <com.google.android.maps.MapView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/mapview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:clickable="true"
        android:apiKey="Your Maps API Key goes here"
    />
    The android:clickable attribute defines whether you want to allow user-interaction with the map. If this is "false" then touching the map does nothing.

 To know the entire Google Map Integration part Click here!!

No comments :

Post a Comment