使用 gomap-plugin 隐藏/查看一组标记
我喜欢使用插件 gomap() 隐藏/查看地图中的一组标记,如下所示: http://www.pittss.lv/jquery/gomap/solutions/group.html
现在我只通过隐藏/查看一个标记来实现这一点:
$(function() {
$("#map_canvas").goMap({
latitude: 46.839,
longitude: 9.285,
zoom: 15 ,
scaleControl: true,
maptype: 'ROADMAP',
markers: [{
latitude: 46.839,
longitude: 9.285,
id: 'biketour1',
group: 'bike',
icon: 'pic/Kategorien/icon_bike.png',
html: {
content: 'Das ist die Biketour1',
popup:false
}
},{
...
}
}],
});
});
$("#bike-check").click(function() {
$.goMap.showHideMarker('bike');
});
你能解释一下我如何实现隐藏/查看吗对于一个团体?我已经在课堂上尝试过了,但这不起作用......
更新:
$(".parentcheck").click(function() {
var group = $(this).attr("id");
switch (group) {
case "bike-check":
showhidemarker("bike");
break;
case "event-check":
//and so on
break;
}
});
/*! show / hiding markergroup
*
* @ groupid Group id string
* @ true Optional boolean to set the visibility to a specific value. If omitted, markers will toggle.
*/
function showhidemarker(groupid){
for (var i in $.goMap.markers) {
$.goMap.showHideMarker($.goMap.markers[i], false);
console.log("it works");
}
$.goMap.showHideMarkerByGroup(groupid, true);
}
这里的html(通过单击复选框,标记应该可见或不可见)
...
<ul>
<li class="checkbox">
<input id="bike-check" class="parentcheck" name="parentcheck" type="checkbox" checked="checked" value="Bike" />
<p>Bike</p>
</li>
<li class="checkbox">
<input id="event-check" class="parentcheck" type="checkbox" checked="checked" value="Events" />
<p>Events</p>
</li>
</ul>
...
问题是,这个方法: $.goMap.showHideMarkerByGroup(groupid, true); 没有正常工作。
单击自行车的复选框后,事件中的标记就会消失 - 但单击自行车复选框后,自行车上的标记就会消失!
怎么了?
I like to hide/view a group of markers in a map with the plugin gomap() like here: http://www.pittss.lv/jquery/gomap/solutions/group.html
for now I realized it with hiding/viewing only one marker:
$(function() {
$("#map_canvas").goMap({
latitude: 46.839,
longitude: 9.285,
zoom: 15 ,
scaleControl: true,
maptype: 'ROADMAP',
markers: [{
latitude: 46.839,
longitude: 9.285,
id: 'biketour1',
group: 'bike',
icon: 'pic/Kategorien/icon_bike.png',
html: {
content: 'Das ist die Biketour1',
popup:false
}
},{
...
}
}],
});
});
$("#bike-check").click(function() {
$.goMap.showHideMarker('bike');
});
Can you explain how I can realize the hiding/viewing for a group? I already tried it with class but this isn't working...
update:
$(".parentcheck").click(function() {
var group = $(this).attr("id");
switch (group) {
case "bike-check":
showhidemarker("bike");
break;
case "event-check":
//and so on
break;
}
});
/*! show / hiding markergroup
*
* @ groupid Group id string
* @ true Optional boolean to set the visibility to a specific value. If omitted, markers will toggle.
*/
function showhidemarker(groupid){
for (var i in $.goMap.markers) {
$.goMap.showHideMarker($.goMap.markers[i], false);
console.log("it works");
}
$.goMap.showHideMarkerByGroup(groupid, true);
}
here the html (by clicking on the checkbox, the markers should be visible or not)
...
<ul>
<li class="checkbox">
<input id="bike-check" class="parentcheck" name="parentcheck" type="checkbox" checked="checked" value="Bike" />
<p>Bike</p>
</li>
<li class="checkbox">
<input id="event-check" class="parentcheck" type="checkbox" checked="checked" value="Events" />
<p>Events</p>
</li>
</ul>
...
the problem is, that this method: $.goMap.showHideMarkerByGroup(groupid, true);
is not working as it should.
The marker from event dissapears by clicking on the checkbox for the bike - but by clicking on checkbox bike the marker from bike should dissappear!
What is wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
知道了 :)
got it :)
更简单的方法是隐藏所有内容并仅显示您需要的内容...GoMap 示例中的示例
Much easier is to hide all and only show the ones you need ... sample from the GoMap examples
如果您使用复选框来显示/隐藏组,则可以这样做(假设复选框的 ID 为“NFLCheckbox”,组的名称为“NFLGroup”):
有关更多详细信息,我在这里写了一篇相关文章:http://www.codeproject.com/Articles/690045/How-to-Display-and-Hide-Marker-Groups-in-Google-Ma
If you use checkboxes to show/hide groups, you can do it this way (assuming the checkbox has the ID "NFLCheckbox" and the name of the group is "NFLGroup" here):
For more detail, I wrote an article about that here: http://www.codeproject.com/Articles/690045/How-to-Display-and-Hide-Marker-Groups-in-Google-Ma