Multiple icons for single feature in ol3
Asked Answered
P

1

5

Is there any (convenient) way to show multiple icons/images for a single vector (point) feature in ol3? Say, for example that I'd like to show different properties of a set of POIs using different icons representing these properties.

I could of course create multiple features for each POI and calculate the required pixel distance between them, but that adds overhead and is a bit awkward.

I would achieve something in the line of: (the yellow dot is the actual POI coordinate):

POI with multiple icons

Peaked answered 14/4, 2015 at 0:32 Comment(0)
B
7

You can have an array of ol.style.Style objects, or a style function (if you need to take into account a feature attribute value) that returns multiple ol.style.Style objects in an array as the value for the style config option.

Bearish answered 14/4, 2015 at 6:12 Comment(2)
Thanks, but not sure that we're talking about the same thing. I am aware that I can dynamically style a set of POIs with different icons using for example a style function, however what I would like to achieve is to have the same POI show multiple icons (I've added an example in my question above). I thought of using an HTML overlay, but am afraid performance would hurt. Another option I though of was actually stitching together a composite icon using canvas.Peaked
Sorry, your answer was in fact what I was looking for. I tested it and it works like a charm. I was not aware a single feature could have multiple styles!Peaked

© 2022 - 2024 — McMap. All rights reserved.