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

前端 未结 4 1764
天涯浪人
天涯浪人 2021-02-04 05:29

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

4条回答
  •  轮回少年
    2021-02-04 06:22

    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.

提交回复
热议问题