谷歌地图 API - 指向地点详细信息页面的链接

Google Maps API - Link to place detail page

本文关键字:详细信息 链接 API 谷歌地图      更新时间:2023-09-26

我有一个自定义的谷歌地图,其中标记是动态填充的,我尝试将标记链接重定向到谷歌地图上相应的地点详细信息页面。例如,在标记单击时,我想打开一个新窗口指向此链接:https://www.google.com/maps/place/PMBCOM/@46.381949,6.236581,17z/data=!3m1!4b1!4m2!3m1!1s0x478c372f7df47135:0xff206d31a973eded

目前,我可以重定向到该地址,但它没有像我之前的链接那样显示完整的"Google我的商家"面板。有什么想法吗?

这是我的代码:

function initMap() {
    var myLatlng = new google.maps.LatLng(agence[0], agence[1]);
    var map = new google.maps.Map(document.getElementById('maps'), {
    center: myLatlng,
    zoom:17
});
var infowindow = new google.maps.InfoWindow();
var service = new google.maps.places.PlacesService(map);
service.getDetails({
    placeId: 'ChIJ71BChS4ujEcRclm9twk3Y04'
}, function(place, status) {
    if (status === google.maps.places.PlacesServiceStatus.OK) {
        var marker = new google.maps.Marker({
        map: map,
        position: place.geometry.location,
        title: place.name,
        url: 'https://www.google.com/maps/place/'+place.formatted_address
});
google.maps.event.addListener(marker, 'click', function() {
    infowindow.setContent(place.name);
    infowindow.open(map, this);
    window.open(marker.url);
  });
}
});
}
google.maps.event.addDomListener(window, 'load', initMap);

感谢您的帮助

看这部分

url: 'https://www.google.com/maps/place/'+place.formatted_address

谷歌无法以这种方式找到这家公司

更改为

url: place.url

我认为这就是你想要的