1

hi i wanted to make a button which is the button will start google map intent with my current location and destination location

how to make a google map automaticlly detect my location and destination longitude and lat? where i put that longi and lat?

i want that map directly draw the direction to destination

     final Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?" 
+ "saddr="+ current_lat+","+current_longi + "&daddr="+dest_address ));

intent.setClassName("com.google.android.apps.maps","com.google.android.maps.MapsActivity");

startActivity(intent); 

alr tried this code but not working

4

3 回答 3

5

尝试将其中之一与 View 意图一起使用:

geo:latitude,longitude
geo:latitude,longitude?z=zoom
geo:0,0?q=my+street+address
geo:0,0?q=business+near+city

就像是:

Uri uri = Uri.parse(<ONE OF THE ABOVE STRINGS>);
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, uri);
startActivity(intent);
于 2013-11-14T15:31:47.977 回答
0
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, 
Uri.parse("http://maps.google.com/maps?saddr=srcLatitude,srcLongitude&daddr=destLatitude,destLongitude"));
startActivity(intent);


// srcLongitude/Latitude = current Location`s longitude/latitude

// destLongitude/Latitude = Destination Location`s longitude/latitude
于 2014-07-17T10:19:57.087 回答
0

试试这个:

String url = "http://maps.google.com/maps?saddr="+currentLattitude+","+currentLongitude+"&daddr="+targetLat+","+targetLang+"&mode=driving";

它应该工作。

于 2013-11-14T14:47:55.697 回答