-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add API for managing a style’s icon images #6436
Comments
I am facing this problem right now. Styling the points with a
I tried to replace the
One possible solution: I could parse the GeoJSON and adding the points manually and filter each annotation inside the delegate method |
Note that iconImage is actually the name of a sprite in the style's sprite sheet, not any arbitrary image in the resource bundle. The feature proposed here would add a way to add an image from your resource bundle to the sprite sheet programmatically. In the meantime, you could use point annotations if you're OK with the differences in behavior. |
If I use point annotations I'd lose the support of clustering, which means, I can only have clustering support with style layers without custom marker or no clustering without style layer with custom markers, right? 🙈 Which leads me to the question on how you're going to implement this proposed feature: Which |
Ah, if you need clustering, then annotations aren’t an option yet: #5814. We don’t expect to implement that in time for the v3.4.0 release, so the short answer to your question is that clustering uses the It is currently possible to take advantage of the fact that annotations are implemented using ordinary style layers. It’s a real kludge, but as a workaround, you could force your own images to be installed as sprites and use them for clustered GeoJSON points: add a dummy MGLPointAnnotation for each image you want to install, so that you can provide an MGLAnnotationImage; from then on, you can use that image as an Note that this workaround relies on several implementation details that can and probably will change without notice in a future release. If you can wait for this issue to be resolved, simply calling |
+1 on this! Sprite: So if I have an image, how is it converted to a (vector?) sprite? Quality / performance degradations/improvements in doing this? How does it know the appropriate size?
While simple and performant, circle annotations aren't that pretty/usable in some real life apps and I'd very much like to see this implemented! |
Sprites are raster images. They’re baked into the style, or you can provide them at runtime via MGLAnnotationImage for point annotations. The proposed API will allow you to add sprites at runtime for more general usage than just annotations. The quality and performance characteristics are equivalent to MGLAnnotationImage usage, except that sprites get wiped away when you switch styles. No resizing takes place.
Nevertheless, as demonstrated by this GL JS example, it’s already possible to make a cluster look different than the individual points it represents. A bubble or bubble with text would use an MGLCircleStyleLayer, while a point-placed image would require an MGLSymbolStyleLayer instead. |
So I tried your workaround @1ec5 but still get Here's how I implemented it:
|
You’ve got it backwards: internally, |
Still no luck when I change it to
😞 |
The reuse identifier shouldn’t have that prefix, though. If it doesn’t work even then, you’ll have to wait for the fix outlined here. |
It doesn't have that prefix. Full implementation details can be found here. You may find a mistake or I may have to wait until this fix is outlined and implemented. |
MGLStyle should have methods for managing a style’s images based on the mbgl support added in #6375. This will make it easier to work with style properties such as
iconImage
.We could either implement
-imageNames
,-image:forName:
, and-setImage:forName:
or a single, mutableimagesByName
dictionary property along the lines of #6097. Images would be straight-up NSImages (on macOS) or UIImages (on iOS). Style images are very closely related toMGLAnnotationImage.image
, but I don’t think we should tangle this API with MGLAnnotationImage at all, because MGLAnnotationImage is sort of a proxy view object while style images only last for the lifetime of the style./cc @incanus @frederoni
The text was updated successfully, but these errors were encountered: