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?
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).
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With