【发布时间】:2015-04-22 14:08:15
【问题描述】:
我有闲置代码:
map: function (events) {
var arrayOfLatLngs = [];
var _this = this;
// setup a marker group
var markers = L.markerClusterGroup();
events.forEach(function (event) {
// setup the bounds
arrayOfLatLngs.push(event.location);
// create the marker
var marker = L.marker([event.location.lat, event.location.lng]);
marker.bindPopup(View(event));
// add marker
markers.addLayer(marker);
});
// add the group to the map
// for more see https://github.com/Leaflet/Leaflet.markercluster
this.map.addLayer(markers);
var bounds = new L.LatLngBounds(arrayOfLatLngs);
this.map.fitBounds(bounds);
this.map.invalidateSize();
}
我最初调用此函数,它会将所有events 添加到带有标记和集群的地图中。
在某个起泡点,我通过了一些其他事件,地图将放大到新事件,但旧事件仍在地图上。
我尝试了this.map.removeLayer(markers); 和其他一些东西,但我无法让旧标记消失
有什么想法吗?
【问题讨论】:
标签: javascript google-maps maps leaflet