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).
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:
getProperties
method to get all the properties, update that object (add properties if needed), then use the setProperties
method. This will trigger a single update in the map.toJson
method which will return a GeoJSON FeatureCollection
, loop over this and update as needed, then use the DataSource's SetShapes
method to overwrite all the data in the data source with the updated data. Again this will trigger a single update in the map.