azure-mapsazuremapscontrol

Can I add anything to Shape.Properties?


In the Azure Map API, the Shape object has add/get/setProperties. Can I use that to add a property I use when handling events on the shape?

And if so, any limits on what names I can use for the key? Is there a set of pre-defined keys that the atlas library is using?

And if I can't use this, what can I use to set an identifier on each shape (in my case they are "pins" in a shape layer).


Solution

  • Yes, you can add properties to the shape when an event occurs. Note that only DataSource's have Shape objects, and clusters will only be Feature types and aside from cluster aggregates, you can't add data to them.

    Not that GeoJSON features have an id property that you can use to set a unique identifier. When passed into a DataSource, it will try and honor that and the wrapped Shape object will have the same ID (Shape objects had a getId method). When create a Shape object, you can also set a unique ID at that time. If you don't a unique ID will be assigned to it automatically.

    In terms of limits: