Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to launch map intent with a marker/overlay item at given latitude and longitude?

I have a latitude and longitude and I want to open google maps centred at that point. So i use the following code for it:

Intent intent = new Intent(android.content.Intent.ACTION_VIEW, 
    Uri.parse("geo:"+lat +","+lng));
startActivity(intent);

However, this does not place a marker on the center. I want to place some kind of marker at the the point I start with (and optionally some kind of name for it). Any idea how this can be achieved?

like image 927
apoorv020 Avatar asked Feb 13 '12 07:02

apoorv020


1 Answers

You can use it like,

Showing Particular Place,

Uri uri = Uri.parse("geo:0,0?q=22.99948365856307,72.60040283203125
                                                               (Maninagar)");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);

Showing Route between to Places,

Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?saddr="+23.0094408+","+72.5988541+"&
                            daddr="+22.99948365856307+","+72.60040283203125));
startActivity(intent);
like image 97
Lalit Poptani Avatar answered Sep 22 '22 12:09

Lalit Poptani