http://jsfiddle.net/9hYv4/1谷歌地图控制按钮
我试图控制我的地图的标签 - 打开和关闭是。
我似乎无法得到它的工作。看上面的小提琴。
我已经定义了我的按钮来调用函数,并且该函数要么显示标签要么不显示标签。
这里是一些代码: 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/
我不知道我在想什么。我所追求的是一个用于切换隐藏/显示图标的复选框。因此,当检查图标显示时,未选中图标被隐藏。
小提琴和jsbin中的代码工作得很好,但是可以在我的贴子小提琴中看到,图标(markerCluster)的分组不再起作用。
点击小提琴并缩小以查看。这些图标应该聚集。
我希望这是明确的?
我非常感谢迄今为止的帮助:)我真的非常感谢花时间来帮助我。
只是为了总结:我是在使用复选框按钮隐藏/显示图标切换之后。并恢复集群功能。
非常感谢你:)
我同意的显示/隐藏顺序是这样更好。但现在与markcluseters他们不会出现在所有了http://jsfiddle.net/9hYv4/6/ – Scientized
jsfiddle代码是不同的,我的例子在jsbin –
我摆脱了按钮,因为它是混淆有'隐藏标记'被检查并且按钮被按下后显示标记。 –