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

Add automated resource loading of icon-images #1000

Closed
wants to merge 1 commit into from
Closed

Conversation

tobrun
Copy link
Member

@tobrun tobrun commented Jun 28, 2019

This PR is a proposal to automate loading of icon-image property of symbols. If core misses an style image, it will emit the image missing event. The symbol manager will pick this up and will attempt to load a drawable from resources with this id. This way users don't need to call addImage themselves, they can just pass in the id of the drawable resource as a String (see here).

Closes #742

@mapbox/maps-android

@chloekraw
Copy link

@tobrun, this is awesome! @julianrex @fabian-guerra, is this also possible on the iOS side?

@chloekraw chloekraw mentioned this pull request Jun 28, 2019
@julianrex
Copy link

Yep, totally.

@fabian-guerra
Copy link

@chloekraw my answer would be yes and no 😅

Unlike Android listeners approach. iOS uses a delegate architecture where the map can "listen" for events and pass this to its single delegate. This means if I implement the delegate in the annotations controller then the developer won't be able to use the map's delegate in his own classes. This is what I mean with "no": I won't be using the same approach.

"Yes" means we can support it with a different approach.

Copy link
Member

@LukasPaczos LukasPaczos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a withIconImage option that accepts a resources ID, convert that to a String when passing to the map and back to an int in the ImageLoader?

plugin-annotation/scripts/annotation_manager.java.ejs Outdated Show resolved Hide resolved
plugin-annotation/scripts/annotation_manager.java.ejs Outdated Show resolved Hide resolved
Copy link
Member

@LukasPaczos LukasPaczos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, could you include a test?

Copy link
Member

@LukasPaczos LukasPaczos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!
Could you add a line with an example to the SymbolOptions#withIconImage(String) javadoc explaining how a drawable name can be used as well?

@@ -146,5 +148,20 @@ static Bitmap getBitmapFromDrawable(Drawable drawable) {
return bitmap;
}
}

@VisibleForTesting
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can changes here be reverted? They seem unused.

@@ -74,12 +81,15 @@ public class <%- camelize(type) %>Manager extends AnnotationManager<<%- camelize
*/
@UiThread
public <%- camelize(type) %>Manager(@NonNull MapView mapView, @NonNull MapboxMap mapboxMap, @NonNull Style style, @Nullable String belowLayerId, @Nullable GeoJsonOptions geoJsonOptions) {
this(mapView, mapboxMap, style, new <%- camelize(type) %>ElementProvider(), belowLayerId, geoJsonOptions, new DraggableAnnotationController<<%- camelize(type) %>, On<%- camelize(type) %>DragListener>(mapView, mapboxMap));
this(mapView, mapboxMap, style, new <%- camelize(type) %>ElementProvider(), belowLayerId, geoJsonOptions, new DraggableAnnotationController<<%- camelize(type) %>, On<%- camelize(type) %>DragListener>(mapView, mapboxMap), new ImageLoader(mapView));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ImageLoader argument addition should be if-checked for symbol manager.

}

@VisibleForTesting
<%- camelize(type) %>Manager(@NonNull MapView mapView, @NonNull MapboxMap mapboxMap, @NonNull Style style, @NonNull CoreElementProvider<<%- camelize(type) %>Layer> coreElementProvider, @Nullable String belowLayerId, @Nullable GeoJsonOptions geoJsonOptions, DraggableAnnotationController<<%- camelize(type) %>, On<%- camelize(type) %>DragListener> draggableAnnotationController) {
<%- camelize(type) %>Manager(@NonNull MapView mapView, @NonNull MapboxMap mapboxMap, @NonNull Style style, @NonNull CoreElementProvider<<%- camelize(type) %>Layer> coreElementProvider, @Nullable String belowLayerId, @Nullable GeoJsonOptions geoJsonOptions, DraggableAnnotationController<<%- camelize(type) %>, On<%- camelize(type) %>DragListener> draggableAnnotationController, ImageLoader imageLoader) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

@stale
Copy link

stale bot commented Sep 20, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the archived Archived by Stale bot. label Sep 20, 2019
@stale
Copy link

stale bot commented Sep 20, 2019

This pull request 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 Sep 20, 2019
@tobrun tobrun reopened this Sep 20, 2019
@stale stale bot removed the archived Archived by Stale bot. label Sep 20, 2019
@oantajames
Copy link

oantajames commented Sep 30, 2019

@tobrun @LukasPaczos any updates on this? 😄 It's currently a blocker, since the update to the latest mapbox sdk version.

@stale
Copy link

stale bot commented Nov 29, 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 Nov 29, 2019
@stale
Copy link

stale bot commented Nov 29, 2019

This pull request 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 Nov 29, 2019
@tobrun tobrun reopened this Nov 29, 2019
@stale stale bot removed the archived Archived by Stale bot. label Nov 29, 2019
@stale
Copy link

stale bot commented Jan 28, 2020

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 Jan 28, 2020
@stale
Copy link

stale bot commented Jan 28, 2020

This pull request 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 Jan 28, 2020
@tobrun tobrun reopened this Jan 28, 2020
@stale stale bot removed the archived Archived by Stale bot. label Jan 28, 2020
@stale
Copy link

stale bot commented Mar 28, 2020

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 Mar 28, 2020
@stale
Copy link

stale bot commented Mar 28, 2020

This pull request 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 Mar 28, 2020
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 this pull request may close these issues.

icon-image loader
7 participants