In the previous post I showed you how to start with google Maps and changing the views and changing the zooming of maps.
Today I will show how to show our desired location in the Map.
For that we need the latitude and longitude of the location we want to show the location on the map.

The only change is in the java code of the previous post.
here is the Modified code

package pack.coderzheaven;

import android.os.Bundle;
import android.view.KeyEvent;


public class MapDemo extends MapActivity {

	MapView map_view;
	MapController mc;
	GeoPoint p;

    public void onCreate(Bundle savedInstanceState) {


        map_view = (MapView)findViewById(;
        map_view.setBuiltInZoomControls(true);    // Show the Zoom Controls
        /** You can also display the map in street view, using the setStreetView() method: **/

        mc = map_view.getController();
        String coordinates[] = {"28.38", "77.12"};
        double lat = Double.parseDouble(coordinates[0]);
        double lng = Double.parseDouble(coordinates[1]);

        p = new GeoPoint(
            (int) (lat * 1E6),
            (int) (lng * 1E6));



	protected boolean isRouteDisplayed() {
		return false;

	public boolean onKeyDown(int keyCode, KeyEvent event)
        MapController mc = map_view.getController();
        switch (keyCode)
            case KeyEvent.KEYCODE_1:
            case KeyEvent.KEYCODE_2:
        return super.onKeyDown(keyCode, event);

Note : Replace the API key with yours in the XML as I have mentioned in the previous post.

Showing a location on Google Maps

Showing a location on Google Maps

Please don’t forget to add your valuable comments on this post, because comments are our encouragements for future posts.


One Comment

  1. Pingback: How to add markers on our desired location in Google Maps Android? | Coderz Heaven

Leave a Reply

Your email address will not be published. Required fields are marked *




Theme by HermesThemes

Copyright © 2018 CoderzHeaven. All Rights Reserved

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.