Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps Static Map using place_id as a parameter

Does anybody know how to use a place_id as a marker location on Static Maps?

In the docs https://developers.google.com/maps/documentation/maps-static/dev-guide#MarkerLocations it does not indicate whether a place_id can be used, but it seems unusual that this would be missing... Google use place_id in most of the other Maps requests.

Thank you

like image 312
myk00 Avatar asked Mar 31 '26 16:03

myk00


2 Answers

Currently place ID is not supported as location in Static Maps API. There is a feature request in Google issue tracker that you can see at

https://issuetracker.google.com/issues/71012469

Feel free to star this feature request to add your vote and subscribe to notifications. Hopefully Google will implement it in the future.

like image 72
xomena Avatar answered Apr 02 '26 21:04

xomena


In the Docs I don't see a way to use the place_id parameter. You can obtain the coordinates of a place_id and then use them in the required parameter center.

var request = {
  placeId: 'ChIJOwE7_GTtwokRFq0uOwLSE9g'
};

var infowindow = new google.maps.InfoWindow();
var service = new google.maps.places.PlacesService(map);

service.getDetails(request, function(place, status) {
  if (status == google.maps.places.PlacesServiceStatus.OK) {
    //My URL
    var gStaticMapURL = "https://maps.googleapis.com/maps/api/staticmap?center=" + place.geometry.location.lat() + "," + place.geometry.location.lng() + "&zoom=14&size=400x400&key=YOUR_API_KEY";

  }
});
like image 37
nmbrphi Avatar answered Apr 02 '26 21:04

nmbrphi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!