Skip to content

Instantly share code, notes, and snippets.

@hanislovingit
Created April 22, 2015 02:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hanislovingit/fd8003c399ae7b74c7a4 to your computer and use it in GitHub Desktop.
Save hanislovingit/fd8003c399ae7b74c7a4 to your computer and use it in GitHub Desktop.
Mapbox-creation-api-layerGroup
// create a LayerGroup object for collecting markers
var markersLayerGroup = L.layerGroup();
// add some markers to the collection
markersLayerGroup.addLayer(marker1);
markersLayerGroup.addLayer(marker2);
// add the collection of markers LayerGroup to the map.
markersLayerGroup.addTo(map);
// or
map.addLayer(markersLayerGroup);
// Note that when we are creating a LayerGroup object, we don't have the option to set its
// visibility on the map, like it does in EntityCollection creation API in Bing map. We make the
// LayerGroup object visible when we add it to the map, and make it invisible when we remove
// it from the map.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment