我使用https://googlemaps.github.io/js-markerclusterer/index.html在谷歌地图上显示和聚类标记。
我使用CDN <script src="https://unpkg.com/@googlemaps/markerclusterer/dist/index.min.js"></script>
加载它。
当我像这样创建markerCLuster时:
clusti = new markerClusterer.MarkerClusterer({ markers, map , renderer});
然后显示所有标记。当我删除标记后,地图是空的。
clusti = new markerClusterer.MarkerClusterer({ markers, map , renderer});
clusti.clearMarkers();
我想清除标记,但不重新绘制地图。意思是,我想保持在地图上的旧标记,直到我增加了新的标记。
从文档来看,这应该是可能的。
https://googlemaps.github.io/js-markerclusterer/classes/MarkerClusterer.html#clearMarkers
但是,当我打电话
clusti = new markerClusterer.MarkerClusterer({ markers, map , renderer});
clusti.clearMarkers({noDraw: true});
标记还没找到。那么,render()似乎又被调用了?我遗漏了什么?
发布于 2022-11-21 14:34:05
尝试clusti.clearMarkers(true);
而不是clusti.clearMarkers({noDraw: true});
https://stackoverflow.com/questions/74503769
复制相似问题