Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Geo: intent with a placeid

I'm trying to make a button to launch google maps on a device and open to a specific place [not just a lat/lon, although that is the fallback].

I have a place id, and want to launch a geo: intent to the place. I can't seem to find the uri structure I need to do that - any ideas?

like image 394
Namingwaysway Avatar asked Nov 27 '15 00:11

Namingwaysway


People also ask

What is Placeid?

A place ID is a textual identifier that uniquely identifies a place. The length of the identifier may vary (there is no maximum length for Place IDs).

How do I find the latitude and longitude of a place id?

From the place_id you got, query Place Details something like https://maps.googleapis.com/maps/api/place/details/json?placeid={placeid}&key={key} and you can get the lat and lng from result. geometry.


1 Answers

I know that this question is old, but it is still a current problem, which isn't until today not implemented by Google. There is no direct URI for that, but I've solved it via the q parameter. First I send the name of the place and then the address. For me it works pretty well.

 Uri gmmIntentUri = Uri.parse("geo:0,0?q=" + place.getName() + ", " + place.getAddress());
 Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
 mapIntent.setPackage("com.google.android.apps.maps");
 startActivity(mapIntent);

If you don't have the address and the name, you can look up this via the Places API Webservice.

like image 64
Julian Schmuckli Avatar answered Sep 29 '22 03:09

Julian Schmuckli