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

Jose Gómez
  • 3,110
  • 2
  • 32
  • 54
averas
  • 545
  • 1
  • 6
  • 15

1 Answers1

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.

bartvde
  • 2,086
  • 11
  • 14
  • 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. – averas Apr 14 '15 at 06:44
  • 1
    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! – averas Apr 14 '15 at 08:34