我为标记添加了一个监听事件,例如
var markers = locations.map(function(location, i) {
return new google.maps.Marker({
position: location,
label: labels[i % labels.length]
});
});
// Add a marker clusterer to manage the markers.
var markerCluster = new MarkerClusterer(map, markers, {
imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m'
});
markerCluster.addListener('click', function() {
console.log('click action');
});
当我单击Google地图上的标记时。我的点击功能不起作用。如何执行这项任务?
最佳答案
您可能需要一个自定义的Google点击处理程序,例如:
google.maps.event.addListener(markerCluster, 'clusterclick', function(cluster) {
// your code here.
});