Last active
August 29, 2015 14:19
-
-
Save hanislovingit/59ba149fbb727da79026 to your computer and use it in GitHub Desktop.
Mapbox-switch-map-view-types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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