Google Map API - 集群标记 - 如何隐藏、禁用或清除选定或过滤的集群标记
首先非常感谢&感谢您对上述挑战的任何帮助、意见或建议。
在我的程序中有两个主要部分,例如:- 1. 按类别或州勾选复选框。 2. 按所选类别或状态划分的 ClusterMarkers
由于我的技术技能和知识有限,如果取消选中该复选框,我将无法清除、禁用或隐藏 clusterMarker。 您尝试过很多方法,例如: -
if ( markerClusterer !== null ) {
markerClusterer.clearMarkers();
}
或 var clear = document.getElementById('clear'); google.maps.event.addDomListener(clear, 'click', clearClusters);
function clearClusters(e) {
e.preventDefault();
e.stopPropagation();
markerClusterer.clearMarkers();
map.clearOverlays();
}
详细计划&数据如下:- 程序-> [jsfiddle] (jsfiddle.net/39tES) 数据-> [jsfiddle] (jsfiddle.net/DELus)
First of all many thanks & appreciated for any help, advice or suggestion to the above challenges.
In my program there are 2 main parts such as: -
1. Checkbox by category or state.
2. ClusterMarkers by selected category or state
Due to my limitted technical skill and knowledge, I'm having problem to clear, disable or hide the clusterMarker if un-check the checkbox.
U have tried many methods such as: -
if ( markerClusterer !== null ) {
markerClusterer.clearMarkers();
}
or
var clear = document.getElementById('clear');
google.maps.event.addDomListener(clear, 'click', clearClusters);
function clearClusters(e) {
e.preventDefault();
e.stopPropagation();
markerClusterer.clearMarkers();
map.clearOverlays();
}
details program & data as follows:-
Program-> [jsfiddle] (jsfiddle.net/39tES)
Data -> [jsfiddle] (jsfiddle.net/DELus)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来您想要多个实例。如果您可以按州级别聚合数据,则可以尝试为每个州/类别创建一个 MarkerClusterer 实例:
然后您可以拥有一个存储实例的对象文字:
然后您可以检测单击的州/类别,并删除/只为该特定实体绘制标记。
It sounds like you want multiple instances. If you can aggregate your data by state level, you could try making a MarkerClusterer instance for each state / category:
then you could have an object literal that stores the instances:
Then you could just detect what state / category was clicked, and remove / draw the markers for just that specific entity.