Closed tobrun closed 4 years ago
What would you suggest in the interim? Since IconFactory
is deprecated, we haven't been successful in finding another way to set custom icon images.
You add images to your style and create an id for them with:
Style.Builder#withImage or Style#addImage
You can use that id with:
Symbol#setIconImage
@tobrun thanks for the quick reply!!!
Updating here that it might make more sense for people reading this issue to start using the new image missing api from https://github.com/mapbox/mapbox-gl-native/pull/14320. This will land as part of the upcoming v7.4.0 release.
The style-spec icon-image is currently exposed as
public void setIconImage(String value) { jsonObject.addProperty("icon-image", value); }
We need an easier way to support Android resources, for example by allow setting a drawable, bitmap or resource id. This setup should also take in account to support re-adding the images if a style changes occurs #737.
@tobrun is there a better way that we could have exposed the icon-image
property on Android?
Updating here that it might make more sense for people reading this issue to start using the new image missing api from mapbox/mapbox-gl-native#14320. This will land as part of the upcoming v7.4.0 release.
Interesting, so this means on Android with https://github.com/mapbox/mapbox-plugins-android/pull/1000, it will be easier to add an arbitrary image at runtime than to add a custom sprite uploaded to Studio at runtime?
@chloekraw in https://github.com/mapbox/mapbox-plugins-android/pull/1000 I'm proposing an alternative way of loading the icons. Just call setIconImage(String value)
with the name of the resource and it will be automatically loaded for you (this includes reloading it during style changes).
@tobrun ahh, I see! the proposed setIconImage(String value)
, where "String value" is the name or ID of the icon-image
, works for both adding custom sprites to the map and arbitrary images, right?
@tobrun ahh, I see! the proposed setIconImage(String value), where "String value" is the name or ID of the icon-image, works for both adding custom sprites to the map and arbitrary images, right?
correct, first core tries to match this value
to an image in the spritesheet. If not found, the plugin will try loading a app resource with the name (fwiw, if no resource is found with that name, we log out message and do not crash the app).
Awesome, thanks @tobrun. That sounds like the ideal developer workflow for using images as icons.
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.
The style-spec icon-image is currently exposed as
We need an easier way to support Android resources, for example by allow setting a drawable, bitmap or resource id. This setup should also take in account to support re-adding the images if a style changes occurs #737.