javascript - Restrict overlays in mapbox -
so creating map using leaflet , mapbox multiple overlays , base maps. have layers control these separated , can show 1 base map @ time, overlays can shown @ once.
however, have 2 overlays interfere each other , make if 1 checked in control, other unchecked , vice versa. there way this?
i anticipating this, open suggestions.
var layer1 = l.mapbox.tilelayer('mapid1'); var layer2 = l.mapbox.tilelayer('mapid2'); var layercontrol = l.control.layers(basemaps, {"l1": layer1, "l2": layer2}).addto(map); map.on("overlayadd", function(e) { if (e.name === "l1"){ l.layers.control.uncheck(layer2); } else if (e.name === "l2") { l.layers.control.uncheck(layer1); }; });
thank you!!
i don't know if there's easier way. seems library doesn't offer many options manipulate l.control.layers
overlays.
what i'm doing firing click on conflicting overlay. achieve this, little dom manipulating needed. can store id reference when creating overlay's label.
Comments
Post a Comment