[英]Google Maps Static Map using place_id as a parameter
有人知道如何使用place_id
作為靜態地圖上的標記位置嗎?
在文檔https://developers.google.com/maps/documentation/maps-static/dev-guide#MarkerLocations 中,它沒有表明是否可以使用 place_id,但似乎不尋常的是它會丟失......谷歌在大多數其他地圖請求中使用 place_id。
謝謝
在文檔中,我沒有看到使用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";
}
});
目前,靜態地圖 API 中不支持地點 ID 作為位置。 您可以在 Google 問題跟蹤器中看到一個功能請求
https://issuetracker.google.com/issues/71012469
請隨意為此功能請求加星標以添加您的投票並訂閱通知。 希望谷歌將來會實施它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.