Search code examples
androidazure-maps

Update position of element in Azure Maps for Android


I'm using the Azure Maps Android SDK to draw icons on the map. The way I'm currently doing this is to add a new Datasource for each element and add a new SymbolLayer using this Datasource and a drawable for the icon. Each time the position of an icon changes I remove this SymbolLayer and add a new one with an updated Datasource. With every position update the icon blinks for a split second and I wish there was a smoother way. While this works I was wondering if this really is the intended way of handling position updates?


Solution

  • You can achieve smooth animated movement of symbols by updating the DataSource itself.

    Changes to the DataSource will be immediately reflected on the map via the existing layers.

    dataSource.clear();
    dataSource.add(featureCollection);