Skip to content
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-image loader #742

Closed
tobrun opened this issue Oct 25, 2018 · 11 comments
Closed

icon-image loader #742

tobrun opened this issue Oct 25, 2018 · 11 comments
Labels
annotation-plugin archived Archived by Stale bot.

Comments

@tobrun
Copy link
Member

tobrun commented Oct 25, 2018

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 tobrun added this to the annotation-future milestone Jan 11, 2019
@chekdotdev
Copy link

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.

@tobrun
Copy link
Member Author

tobrun commented Feb 5, 2019

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

@chekdotdev
Copy link

@tobrun thanks for the quick reply!!!

@tobrun
Copy link
Member Author

tobrun commented May 9, 2019

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.

@chloekraw
Copy link

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 #1000, it will be easier to add an arbitrary image at runtime than to add a custom sprite uploaded to Studio at runtime?

@tobrun
Copy link
Member Author

tobrun commented Jun 28, 2019

@chloekraw in #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).

@chloekraw
Copy link

@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
Copy link
Member Author

tobrun commented Jul 1, 2019

@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).

@chloekraw
Copy link

Awesome, thanks @tobrun. That sounds like the ideal developer workflow for using images as icons.

@stale
Copy link

stale bot commented Dec 28, 2019

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.

@stale stale bot added the archived Archived by Stale bot. label Dec 28, 2019
@stale
Copy link

stale bot commented Dec 29, 2019

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

@stale stale bot closed this as completed Dec 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
annotation-plugin archived Archived by Stale bot.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants