To Use Google map API few things you have do
Sign Up for Google Map API
Get the MD5 from your local machine :
And enter the code here and generate the API code (Which looks like below image)
and add code to res/layout/main.xml
Now geol.java extend
In AndroidManifest.xml You also need access to the Internet in order to retrieve map tiles, so you must also request the
And now Run the application
Output :
Sign Up for Google Map API
Get the MD5 from your local machine :
$ keytool -list -keystore ~/.android/debug.keystore
like
Certificate fingerprint (MD5): 8E:EA:04:13:F2:A8:A6:E6:A3:A5:20:96:9E:0A:30:DB
And enter the code here and generate the API code (Which looks like below image)
and add code to res/layout/main.xml
<com.google.android.maps.MapView
android:id="@+id/myGMap"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="0T3dTjk2jvhmuFEAdn4DjX08e3eEeA-IoYEnWag" /*Your API key here*/
/>
Now geol.java extend
the class MapActivity
instead of Activity
gMapView = (MapView) findViewById(R.id.myGMap);
gMapView.setSatellite(true);
mc = gMapView.getController();
// Adding zoom controls to Map
ZoomControls zoomControls = (ZoomControls) gMapView.getZoomControls();
zoomControls.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
gMapView.addView(zoomControls);
gMapView.displayZoomControls(true);
//This method is required for some accounting from the Maps service to see if you're currently displaying any route information. In this case, you're not, so return false.
@Override
protected boolean isRouteDisplayed() {
return false;
}
In AndroidManifest.xml 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
element:
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
And now Run the application
Output :
Comments