a. ADT is already installed (Reference : Installation of Android Development Tools (ADT))
b. Google map key (Reference : How to generate google map key.html)
c. Google API (Install Google API if not already installed)
(Google API = map api + android api)
Use Eclipse to install Google API as shown below
----------------------------------------------------------------------------------
Project Structure :
----------------------------------------------------------------------------------
Setting Emulator for Google Map Application :
- Select Target : "Google API" as shown below
(In the Target, Google API option is available after installing Google API using Android SDK Manager in Eclipse)
Steps to create Map based application :
1) Create Activity which extends MapActivity
package com.namasteandroid.mapapp;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
public class MyMapsActivity extends MapActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String mapKey = "0CJatumMJbC7I_ZPfoi5gQWZffw"; //Replace this key with yours
MapView mapView = new MapView(this, mapKey);
mapView.setEnabled(true);
mapView.setClickable(true);
mapView.setBuiltInZoomControls(true);
setContentView(mapView);
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
----------------------------------------------------------------------------------
2) Modify Manifest (/res/AndrodManifest.xml) add below lines highlighted in orange
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.namasteandroid.mapapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".MyMapsActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-library android:name="com.google.android.maps" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
----------------------------------------------------------------------------------
3) Output