Google Maps API - 链接到地点详细信息页面

时间:2016-04-25 15:47:34

标签: javascript google-maps google-maps-api-3

我有一个自定义的Google地图,其中标记是动态填充的,我尝试将标记链接重定向到相应的地方详细信息' Google地图上的页面。例如,在标记点击时,我想打开此链接的新窗口: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);

感谢您的帮助

1 个答案:

答案 0 :(得分:1)

看这部分

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

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

更改为

url: place.url

我认为这就是你想要的