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...

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.

| improve this answer | |
  • Indeed it works - I had it in the wrong place in my JS file. Sorry for that. – Raphael May 31 '16 at 12:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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