mapbox / leaflet-image

leaflet maps to images
http://mapbox.github.io/leaflet-image/
BSD 2-Clause "Simplified" License
364 stars 142 forks source link

Tilelayer opacity is not supported #124

Open mho22 opened 5 years ago

mho22 commented 5 years ago

I'm trying to generate an image of a Tilelayer.WMS with an opacity of 0.5 but leaflet-image always generate an image with 100% opacity :

{
            layers: layerName,
            styles: styleName,
            format: 'image/png',
            transparent: true,
            opacity: 0.5,
}

Do you have an idea of the issue ? Am I the only one having this issue ?

mho22 commented 5 years ago

Added this line into handleTileLayer function , works like a charm :

ctx.globalAlpha = (layer.options && layer.options.opacity) ? layer.options.opacity : 1;

I'm suggesting a pull request