Open davidbrochart opened 6 years ago
No, there is not, but I implemented it in my forked repo. Sent the PR #17, which allows setting the opacity after merging (see README for usage examples). You should be able to adapt this easily.
@m-mohr do you have a working example hosted? setting the globalAlpha does not seem to work for my use case.
@kcjonesevans No, sorry, I haven't. If you are using the code from my fork you don't need to set the globalAlpha manually, just set the opacity in the options like this:
var windDirection = L.leafletGeotiff(
'https://stuartmatthews.github.io/leaflet-geotiff/tif/wind_direction.tif',
{
band: 0,
name: 'Wind direction',
opacity: 0.5,
renderer: L.LeafletGeotiff.vectorArrows({
arrowSize: 20
})
}
).addTo(mymap);
It works in the demo files from Stuart. If this doesn't help, could you send me your use case so that I can fix it?
Also can not reproduce a working case with the opacity setting
More information about your setup would have helped to reproduce the problem. Anyway, I just found out that it doesn't work in some raster use cases, a fix has been pushed to my repo and the PR #17 has been updated, too. Here is a demo: http://mamo-net.de/feature/leaflet-geotiff/demo.html Can one of you, @pushcommit or @kcjonesevans, confirm that it works for your use-cases? Afterwards @stuartmatthews may want to consider merging the PR.
This works for my use-case. Since the fix is using image.style, is it safe to assume other style attributes could be changed on the geotiff with a similar command, i.e. applying desaturation or greyscaling?
@kcjonesevans Yes, should be possible for raster images that use the img-tag to be displayed. Though the mentioned filters are not as widely supported by browsers as opacity is. For the vector data from the tiffs you'd need another approach to make it work consistently across all use-cases that uses canvas based rendering. When using plotly as renderer you can also use it for further styling.
Opacity is supported out of the box in https://github.com/GeoTIFF/georaster-layer-for-leaflet
Is there a way to set the opacity (alpha value)?