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…
Best Answer
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.