How to generate Google Map Key ?

1. Signup for Android Map API key (it allows to embed Google maps in Android App)

2. Use your Google account to finally generate Map Key

3. Generate your certificate's MD5 fingerprint
i)  Check for debug.keystore on your machine under [.android] directory
        Example on MacOS:
        /Users/santoshlg/.android/debug.keystore

ii) Check for the keytool location on your machine (JDK installation)  
        Example on Windows:
     C:\Program Files\Java\jdk1.6.0_21\bin\keytool
   
iii) Use below command to list contents of existing debug.keystore
            $keytool -list -keystore ~/.android/debug.keystore

     Enter keystore password: android
     Keystore type: JKS
     Keystore provider: SUN
     Your keystore contains 1 entry

     androiddebugkey, Jun 26, 2010, PrivateKeyEntry,
     Certificate fingerprint (MD5): 8A:B7:F5:D4:0F:F3:FA:31:E6:24:D6


iv) Access below URL and enter Certificate fingerprint (MD5) generated above 
           URL: http://code.google.com/android/maps-api-signup.html

v) Finally you will get page similar to below,
      

4. Use Map key (generated above) in your application code so that your application can use Google Map API (Important : Please go through the Google Policy for Using their API in your code)
i) Create Activity which extends MapActivity
import android.os.Bundle;

import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;

public class MyMapsActivity extends MapActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.main);
        String mapKey = "0CXT_1IuVXHJUxJatumMJbC7I_Zw"
        MapView mapView = new MapView(this, mapKey);
        mapView.setEnabled(true);
        mapView.setClickable(true);
        mapView.setBuiltInZoomControls(true);
        setContentView(mapView);
        
    }

@Override
protected boolean isRouteDisplayed() {
return false;
}
}

For detail map application please refer to below blog post,
http://namaste-android.blogspot.jp/2012/04/using-google-map-in-your-application.html

No comments :

Post a Comment