dimanche 20 décembre 2015

how to add or remove layers on mapbox

I have many markers and polygon i just add them to the map as L.mapbox.featureLayer objects. Now i want to show layers if checkbox is checked, and hide/remove layer if checkbox is unchecked.

<input type="checkbox" name="hospital" value="hospital"> Hospital<br>
<input type="checkbox" name="library" value="library" checked>Library<br> 

it's my checkbox

var hospitalLayer = L.mapbox.featureLayer(hospitals)
    .addTo(map);
var libraryLayer = L.mapbox.featureLayer(libraries)
    .addTo(map);

If i check hospital it's show only hospital markers on map. How to do this?




Aucun commentaire:

Enregistrer un commentaire