-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Icon added using addImage
not rendering consistently.
#9263
Comments
Thanks for the example! const imageEl = document.createElement('img');
imageEl.onload = () => mapboxglMap.addImage(id, imageEl);
imageEl.height = 70;
imageEl.width = 70;
imageEl.src = "data:image/png;base64,...", We should either:
|
@ansis Thanks! Didn't realize data URLs need to be loaded too. 🤦♂ Indeed with those changes, my example appears to now load the icon consistently. Might be a day or two until I can test out those changes for my particular use case, but it looks like this should solve the icons not rendering there as well. 🙇 |
FWIW I added the
(Yes, mapbox-gl-js should support loading images directly from URL. It's a very common need.) |
In summary, for the show layer on map correctly I need to complete next steps:
But it not work in case icon name takes from source. Need additional step for parse geojson source. |
mapbox-gl-js version: 1.7.0 (also reproduced in 1.3.1)
browser: Chrome Version 79.0.3945.130 (Official Build) (64-bit)
Steps to Trigger Behavior
map.addImage
to add a base64 encoded image.Link to Demonstration
Expected Behavior
The icon consistently appears on the map.
Actual Behavior
The icon only sometimes appears on the map.
Some background on my use case
This may tie into the future plans mentioned here: #9226 (comment)
My use case is to be able to render X features per tile, where X can vary from 0 to no more than 50 features and a subset of those features use a unique custom icon.
The reason I'm using base64 encoded images is so I can return images along with a tile's features in lieu of a better solution that performs better than fetching images separately.
The text was updated successfully, but these errors were encountered: