2

I have a MultiPoint feature with the following GeoJSON:

{
    "type": "Feature",
    "geometry": {
        "type": "MultiPoint",
        "coordinates": [
            [
                -123,
                58
            ],
            [
                -152.32,
                17.5
            ],
            [
                52.02,
                42.64
            ]
        ]
    }
}

When I draw this on map and apply any icon through a style function, its applied for all points. But I would like to show all the three coordinates above with different icons on map. Is there any way I can add different markers for each coordinates in a Multipoint feature?

  • @BradHards. So what you mean to say is its not possible to have different markers for them? – BiJ Dec 21 '16 at 8:57
  • Tried to turn it into an answer. I think that even if you do find some workaround (which I can't think of, beyond what I put in the answer), its probably indicating a data design issue in any case. – BradHards Dec 21 '16 at 9:00
2

I think you have a conceptual problem - if your three coordinate pairs do not represent the same thing, then you don't really have MultiPoint. MultiPoint is three locations that are intrinsically the same feature. Not different instances of the same kind of feature, but really just one feature that needs three locations to represent it.

If you need to style it differently, break it up using getPoints(), copy whatever attributes really should be common, and style / handle each point separately.

0

Look at the geometry-based style function example, that should give you an idea on how to handle this:

http://openlayers.org/en/latest/examples/polygon-styles.html?q=geometry+style

  • I have already gone through that. But didn't find the solution. – BiJ Dec 21 '16 at 11:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.