我在ngx-leaflet-markercluster中使用了角度显示共享相同位置的标记簇。虽然设置了标记,但它给出了错误addeventparent不是函数。
// ts
const data: Marker[] = res.map(loc => {
if (loc.STATUS === this.appConstantsService.OUTAGE_STATUS.INACTIVE) {
return { lat: loc.location_details_lat, lon: loc.location_details_lon, icon: '/assets/icons/marker-0.png' };
} else {
return { lat: loc.location_details_lat, lon: loc.location_details_lon, icon: 'assets/icons/marker-1.png' };
}
});
this.markerClusterData = data;
// html
<div leaflet style="height: 600px;"
[leafletOptions]="options"
[leafletBaseLayers]="baseLayers"
[leafletMarkerCluster]="markerClusterData"
[leafletMarkerClusterOptions]="markerClusterOptions"
(leafletMarkerClusterReady)="markerClusterReady($event)"
>
</div>
我希望标记具有相同的纬度和经度时出现在群集中,当我单击群集时应放大并显示标记。首先我正在使用agm map。当两个标记共享相同的标记时出现问题lat和long。我使用了agm-marker-cluster和agm-maker-spider,但其中没有解决方案。是否有其他解决方法
答案 0 :(得分:0)
我们必须使用标记类来添加标记
const data: Marker[] = res.map(loc => {
if (loc.STATUS === this.appConstantsService.OUTAGE_STATUS.INACTIVE) {
const icon = L.icon({ iconUrl: '/assets/icons/marker-0.png' });
return marker([loc.location_details_lat, loc.location_details_lon], { icon });
} else {
const icon = L.icon({ iconUrl: '/assets/icons/marker-1.png' });
return marker([loc.location_details_lat, loc.location_details_lon], { icon })
}
});