[英]Google Maps: Google Places JS API: getDetails() not returning entire place details
I'm trying to show 2 locations on a map that when clicked display all the place details in their respective infowindows. 我正在尝试在地图上显示2个位置,单击这些位置将在其各自的信息窗口中显示所有地点详细信息。 I can only get a return of very limited place details to show, namely the address and that's about it.
我只能得到非常有限的地点详细信息来显示,即地址,仅此而已。 You can see here: http://www.intermountainvet.com/contact-0 .
您可以在这里看到: http : //www.intermountainvet.com/contact-0 。 I am console logging the place objects.
我在控制台记录地方对象。
I know that there is a robust google place for this business, you can see here: https://www.google.com/maps/place/Intermountain+Pet+Hospital+%26+Lodge/@43.5906437,-116.4033528,15z/data=!4m6!1m3!3m2!1s0x0:0x2a5e055f442189ea!2sIntermountain+Pet+Hospital+%26+Lodge!3m1!1s0x0:0x2a5e055f442189ea 我知道有一家适合该业务的Google地方,您可以在这里查看: https : //www.google.com/maps/place/Intermountain+Pet+Hospital+%26+Lodge/@43.5906437,-116.4033528,15z/数据=!4m6!1m3!3m2!1s0x0:0x2a5e055f442189ea!2s山间小屋+宠物+医院+%26 +住宿!3m1!1s0x0:0x2a5e055f442189ea
Why can't I access all of those place details to display in my infowindow? 为什么我不能访问所有这些地方详细信息以显示在我的信息窗口中?
Here is my code. 这是我的代码。 (I have my api key and the libraries=places src in a script tag that I'm not showing here):
(我在未显示的脚本标签中有我的api密钥和thelibraries = places src):
<script type="text/javascript">
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 43.618928, lng: -116.274319},
zoom: 11
});
var infowindow = new google.maps.InfoWindow();
var service = new google.maps.places.PlacesService(map);
var locA = service.getDetails({
placeId: 'ChIJa_maRXxRrlQRSimVL1yUG8Q'
}, function(place, status) {
console.log(place);
console.log(status);
if (status === google.maps.places.PlacesServiceStatus.OK) {
var marker = new google.maps.Marker({
map: map,
position: place.geometry.location
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent('<img src="' + place.icon + '" /><font style="color:#000;">' + place.name +
'<br />Rating: ' + place.rating + '<br />Vicinity: ' + place.vicinity + '</font>');
infowindow.open(map, this);
});
}
});
var locB = service.getDetails({
placeId: 'ChIJow1xfMRUrlQR6ewuO4NvrF0'
}, function(place, status) {
console.log(place);
console.log(status);
if (status === google.maps.places.PlacesServiceStatus.OK) {
var marker = new google.maps.Marker({
map: map,
position: place.geometry.location
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent('<img src="' + place.icon + '" />font style="color:#000;">' + place.name +
'<br />Rating: ' + place.rating + '<br />Vicinity: ' + place.vicinity + '</font>');
infowindow.open(map, this);
});
}
});
}
Thanks for looking. 感谢您的光临。 I feel like this should be simple and I must be missing something minor.
我觉得这应该很简单,并且我必须缺少一些小东西。
您需要使用商家的地点ID(ChIJa_maRXxRrlQR6okhRF8FXio)而不是地址(ChIJa_maRXxRrlQRSimVL1yUG8Q)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.