2

单击时的标记将调用一个名为 calcRoute 的函数。单击标记时,我还想在标记附近显示文本内容。

var textContent = "Some text";

var marker = new google.maps.Marker({
            map: map,
            title: MALL.mall.name,
            position: pos
        });

google.maps.event.addListener(marker, 'click', (function () {
            calcRoute();
        }));
4

1 回答 1

2

看到您已将问题标记为“infowindow”,您应该尝试一下:

var infowindow = new google.maps.InfoWindow({
    content: textContent
});

google.maps.event.addListener(marker, 'click', (function () {
    calcRoute();
    infowindow.open(map, marker);
}));

https://developers.google.com/maps/documentation/javascript/overlays#InfoWindows

于 2012-07-26T18:34:51.467 回答