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?
got it 🙂