Skip to content

Instantly share code, notes, and snippets.

@hanislovingit
Last active August 29, 2015 14:19
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/59ba149fbb727da79026 to your computer and use it in GitHub Desktop.
Save hanislovingit/59ba149fbb727da79026 to your computer and use it in GitHub Desktop.
Mapbox-switch-map-view-types
var mapboxSatelliteLayer = L.mapbox.tileLayer('satelliteMapboxMapId'); // default map
var mapboxStreetLayer = L.mapbox.tileLayer('streetMapboxMapId');
function (val) {
switch (val) {
case '0':
if (_map.hasLayer(mapboxSatelliteLayer)) {
_map.removeLayer(mapboxSatelliteLayer);
}
_map.addLayer(mapboxStreetLayer);
break;
case '1':
if (_map.hasLayer(mapboxStreetLayer)) {
_map.removeLayer(mapboxStreetLayer);
}
_map.addLayer(mapboxSatelliteLayer);
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment