Skip to content

Instantly share code, notes, and snippets.

@wboykinm
Created December 18, 2012 20:40
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 wboykinm/4331759 to your computer and use it in GitHub Desktop.
Save wboykinm/4331759 to your computer and use it in GitHub Desktop.
toggle and switch layers called my mapbox.js
layer.onclick = function(e) {
e.preventDefault();
e.stopPropagation();
//Something here that disables all layers before proceeding to the next step
// e.g.
$.each(map.layers, function(l) {
l.disable();
});
map.getLayer(this.id).enabled ? map.getLayer(this.id).disable() : map.getLayer(this.id).enable();
this.className = map.getLayer(this.id).enabled ? 'active' : '';
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment