Reputation: 2446
I have 2 Place IDs I've obtained via the Google Places API, and want to display a link to the Google Maps app for directions between those 2 places.
I see that it's possible to do this with 2 addresses based on the answer at Current Location - Google Maps - Link to Directions using the saddr
and daddr
query parameters
I also see that it's possible to link to a map with a place ID by prefixing place_id:...
in the q
query parameter from this answer at Getting Google Maps link from place_id
Is there a way to have a directions link with the Google place_id? I tried a URL like:
https://www.google.com/maps/dir/place_id:ChIJp4JiUCNP0xQR1JaSjpW_Hms/place_id:ChIJp4JiUCNP0xQR1JaSjpW_Hms
and it doesn't seem to work
Upvotes: 3
Views: 3798
Reputation: 32178
In order to open Google Maps directions mode with place IDs you have to use Google Maps URLs. The Google Maps URLs in directions mode support parameters origin_place_id
and destination_place_id
.
Create the following URL for example (note that origin and destination parameters are also mandatory as per documentation)
https://www.google.com/maps/dir/?api=1&origin=Yukar%C4%B1%20Bah%C3%A7elievler%2C%2070.%20Sk.%2017%2FB%2C%2006490%20%C3%87ankaya%2FAnkara%2C%20Turkey&origin_place_id=ChIJp4JiUCNP0xQR1JaSjpW_Hms&destination=Be%C5%9Fikkaya%2C%202044%2F1.%20Sk.%2C%2006230%20Alt%C4%B1nda%C4%9F%2FAnkara%2C%20Turqu%C3%ADa&destination_place_id=ChIJn-ZptRFT0xQRGUyoJX2s8Wc
Have a look at the documentation for further details.
I hope this helps!
Upvotes: 5