【发布时间】:2014-02-14 12:19:51
【问题描述】:
我正在尝试控制我的地图的标签——打开和关闭。
我似乎无法让它工作。参见上面的小提琴。
我已经定义了我的按钮来调用函数,以及显示或不显示标签的函数。
这里是一些代码: JAVASCRIPT:
// Removes the markers from the map, but keeps them in the array.
function clearMarkers() {
setAllMap(null);
}
// Shows any markers currently in the array.
function showMarkers() {
setAllMap(map);
}
HTML:
<div id="panel">
<input onclick="clearMarkers();" checked="checked" type="checkbox" value="Hide Markers"><label>Hide Markers</label>
<input onclick="showMarkers();" type="button" value="Show All Markers">
</div>
编辑
请看这里: http://jsfiddle.net/9hYv4/10/
我不知道我在想什么。我所追求的是一个切换隐藏/显示图标的复选框。因此,选中时图标显示,未选中时图标隐藏。
fiddle 和 jsbin 中的代码运行良好,但是从我发布的 fiddle 中可以看出,图标分组(markerCluster)不再起作用。
点击小提琴并缩小查看。这些图标应该聚集在一起。
我希望这很清楚?
我非常感谢迄今为止的帮助 :) 我非常感谢您花时间帮助我。
总结一下:我在使用复选框按钮隐藏/显示图标切换之后。并恢复集群功能。
非常感谢:)
【问题讨论】:
标签: javascript google-maps button click