【问题标题】:Google Maps Static Map using place_id as a parameter使用 place_id 作为参数的谷歌地图静态地图
【发布时间】:2018-09-25 07:07:21
【问题描述】:
【问题讨论】:
标签:
javascript
google-maps
google-static-maps
【解决方案2】:
在Docs 中,我看不到使用place_id 参数的方法。
您可以获取place_id的坐标,然后在必填参数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";
}
});