Skip to main content

Use Google Map API with Android

To Use Google map API few things you have do

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

Popular posts from this blog

Welcome 2009 ...A new year resolution

A new year resolution I think this is a good time to sit back and reflect on the things we'v done and those we hvnt,the thingz we'v done right and those we did wrong,and the times we impressed and dissapointed ourselves and others..THEN make decisions based on our thoughts. I thought to write this year resolution that is to be SMART ( Specific, Measurable, Achievable, Realistic and Time-bound ) and listed to on my blog HAPPY NEW YEAR EVERYONE!! Live UR Life

Are you afraid of the dark!!! -Sidney Sheldon

I have just finished reading this book ............... The book starts with the cops who find the dead bodies of various scientists. It tells us briefly about the lives of the two widows when they were married rather happily married. One widow being a high profile model the other being a girl next door kind of a person. This book is a story of the wives of two good scientist who escape death several times. The two lose their husband as they were murdered for being involved in a very high profile undercover project. The book describes how the two widows decide to find out the person involved in murdering their husband and in the process how do they escape death several times and finally whether did they die or not ? is a question which will be answered only after reading the book. ARE YOU AFRAID OF THE DARK? is a pleasant and easy read. While the story has its flaws, it certainly held my interest and kept me reading to the very end.

Touching One .......................

Little girl and her father were crossing a bridge. The father was kind of scared so he asked his little daughter, "Sweetheart, please hold my hand so that you don't fall into the river. " The little girl said, "No, Dad. You hold my hand. " "What's the difference?" Asked the puzzled father. "There's a big difference, " replied the little girl. "If I hold your hand and something happens to me,chances are that I may let your hand go. But if you hold my hand, I know for sure that no matter what happens, you will never let my hand go. " In any relationship, the essence of trust is not in its bind, but in its bond. "So hold the hand of the person whom you love rather than expecting them to hold urs... this story tells many things... u just need to understand the meaning rest depends on u "