How do I get a direct link to a place on google maps with the Place Id
Asked Answered
R

4

27

I have the Place Id of a place on google maps in my app. Is there a way to put the place Id in a URL and have it directly link to the page? Or does it have to be done through the URL?

I can't seem to find anything detailing this in the docs. I've tried below, but it just gets me the standard google maps page:

https://maps.google.com/maps?placeid=ChIJN1t_tDeuEmsRUsoyG83frY4
Rheum answered 26/5, 2015 at 19:46 Comment(2)
possible duplicate of How to get location coordinates knowing place_id via google javascript apiLangill
possible duplicate of Google Map add marker using place IDLangill
T
55

Recently, in May 2017, Google launched the new Google Maps URLs API. You can read about this API in the official documentation

https://developers.google.com/maps/documentation/urls/guide

So, from now on you can construct a URL for Google Maps using the place ID. In your particular case this URL will be

https://www.google.com/maps/search/?api=1&query=Google&query_place_id=ChIJN1t_tDeuEmsRUsoyG83frY4

Hope this helps!

Triplett answered 23/5, 2017 at 14:41 Comment(2)
Note that this url is not supported on iOS 11 since it tries to open the maps app and then fails.Stereo
query parameter is required, it is used as a fallback if place_id is not found (so put something relevant: &query=${encodeURIComponent(<place name>)}). api=1 is required as well and the only possible value is 1 (sic). It's all in the docs cited above. One always needs to read the docs first. Gosh.Pathogen
P
1

The URL for a specific Google Place is returned by the places details API endpoint.

If for example you query:

https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJV2BQ4laeekgRFauLvdXbFXE&key=YOUR_API_KEY

You will see that in the returned JSON there is a key 'url' which points to https://maps.google.com/?cid=8148660811851344661

Psid answered 7/2, 2017 at 6:26 Comment(0)
R
0

Not directly, using the placeID you can get a variety of information in JSON or XML format, among them there are also the lat lng of the place and its address with which you can easily locate the map google developer doc

Reel answered 26/5, 2015 at 20:20 Comment(0)
D
-2

The correct format, at this time, to produce a general link that goes directly to correct google place is: https://maps.google.com/?cid=[place_id]&t=[maptype]

The map type parameter "t" is apparently necessary. Without it, google maps seems to perform a more general search when the link opens that is sometimes successful and sometimes not. With it, maps opens to correct place each time whether it opens in browser or in app on mobile.

Set this parameter to "m" for a street map and "k" for a satellite map.

A lot of answers on SO show the following syntax which often pulls unwanted results if two locations of the same name are nearby e.g.: https://www.google.com/maps/place/Starbucks/@43.088554,-88.06579,17z/

If you are already using google places api, then you have the place_id, so i recommend using it to avoid ambiguity.

Deport answered 7/9, 2016 at 0:58 Comment(2)
@Shane what was the source for your place id? google uses multiple formats for place idsDeport
for example: use: maps.google.com/?cid=13658998061326453845&t=kDeport

© 2022 - 2024 — McMap. All rights reserved.