我已经在角度应用程序的地图(javascript v3)中设置了clustererMarker,并希望在选定的集群上打开InfoWindow。但是,当我单击单个标记时,群集再次出现,并且缩放丢失。是否可以通过群集标记将点击事件保留在标记上?谢谢,
我的代码是:
/**
* loop for create marker
**/
for (let i = 0; i <= objects.length - 1; i++) {
const posMarker = {lat: sabres[i].latitude, lng: sabres[i].longitude};
const marker = new google.maps.Marker({
position: posMarker,
map: this.map,
title: objects[i].name,
});
}
/**
* function to open infoWindow
*/
marker.addListener('click', function () {
const markerContent = this.setMarkerContent(this.title, objects[i]);
this.infoWindow = new google.maps.InfoWindow({
content: markerContent
});
this.infoWindow.open(this.map, marker);
this.map.setZoom(11);
..
});
/**
* add cluster markers
*/
this.MarkerClusterer = new MarkerClusterer(this.map, this.markers,
{imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m'});
答案 0 :(得分:0)
我发现了问题。在用于标记的InfoWindow上,在重新启动集群视图的InfoWindow打开后,我已经在标记上设置了缩放比例。