-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support non-sprite images #563
Comments
Generating sprites from individual images is an easy process, e.g. using spritezero-cli. And sprite sheets are more efficient than individual images. So I'd recommend looking into that instead. |
For static images that might be ok. However, we need to support dynamic environments and (relatively) unskilled administrators:
As opposed to
And of course a sprite is useless, if images are dynamically generated based on the data in the features. If there was a way to just wrap the style function without duplicating the logic, that might be better, but I don't see a way. |
In my workflow, the user puts the desired image in a directory and runs
Then the uploaded image will be available in a 1x and 2x resolution sprite sheet, available under the name of the file that the user uploaded (e.g. But like I proposed in #561 (comment), a style modification hook would also allow you to bypass sprites and provide images in a different way. |
@ahocevar: add the style modification hook: where (which class) would this be? |
The options can be passed to any of the API functions, and are carried on all the way down to |
@cns-solutions-admin Digging a bit more into this, I think an API like mapbox-gl-js's would be nice: import { addImage } from 'ol-mapbox-style';
addImage('myimage', 'path/to/myimage.png', {pixelRatio: 1});
addImage('myimage', 'path/to/[email protected]', {pixelRatio: 2}); Then this image would be available as if |
Yes, as described above, with mapbox we used addImage, but also the "styleimagemissing" event:
However, for use in the stylefunction this would add to much complexity, so I just added a function
I think that the mapbox styling could use a radical refactoring, e.g.
By having a class, it can be extended, pre-/postprocessing can be easily added into the functions, ... But until that time I still think, my approach with the additional optional |
In Mapbox you can add images to the map (see https://docs.mapbox.com/mapbox-gl-js/api/map/#instance-members-images) either statically by loading them before use or dynamically as response to a "styleimagemissing" event.
We used this
Even with OpenLayers we prefer to configure our layers with mapbox style JSONs and would like to add this possibility to the stylefunction, e.g.
The text was updated successfully, but these errors were encountered: