单击时的标记将调用一个名为 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();
}));
最佳答案
看到您已将问题标记为“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
关于javascript - 我在谷歌地图上有一个标记,点击后应该显示文本内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11675715/