3

I am working with mapbox.js and leaflet to create a map with a number of overlapping tilelayers. I want to apply some custom CSS to only selected tilelayers, and thus assign these layers to an additional custom CSS class like this:

var layer = L.mapbox.tileLayer(layername).addTo(map);
layer.getContainer().className += ' custom'; 

Unfortunately, the above did not do the trick, though. Any hints on how to assign a custom CSS class to a given tilelayer in leaflet/mapbox would be very welcome...

1 Answer 1

3

This was added as a new feature in Leaflet just a few days ago. That feature will be part of the v1.0.0-rc2 release.

Also, your method works well, as demonstrated here.

2
  • Indeed it works - I had it in the wrong place in my JS file. Sorry for that. Commented May 31, 2016 at 12:17
  • ?? where the code? please copy/paste here Commented Jan 9, 2022 at 22:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.