In my Azure Map (JS), I have the following code that displays various pins on the map. As the datasource changes, I clear the last set of Sources and add a new array of Sources.
datasource.clear();
datasource.add(sourceData);
After the .add call, there is a time delay before all the new pins are displayed. How can I detect when this operation is complete? Is there an event that exposes this?
When the clear and the add functions are called, they each causes a rerender of the map to occur. Since these two function calls are one after the other, this can cause the delay you are seeing. The Azure Maps team added another function which overwrites the data in the data source and only does one rerender. Uses the data sources setShapes
function instead.
datasource.setShapes(sourceData);
Documentation for this function can be found here: https://learn.microsoft.com/en-us/javascript/api/azure-maps-control/atlas.source.datasource?view=azure-maps-typescript-latest#setshapes-featurecollection---array-feature-atlas-data-geometry--any----atlas-data-geometry---shape--