MapView.graphicsOverlays.add does not update the UI

498
2
12-12-2022 09:22 AM
JulianBissekkou
New Contributor III

I am adding a new GraphicOverlay to my map using `mapView.graphicsOverlays.add` but it does not update the UI. Once you move or tap the map it refreshes and the new graphics are shown.

 

In my case I am drawing a polygone.

Is there anything that I am missing?

0 Kudos
2 Replies
RamaChintapalli
Esri Contributor

Hi,
Can you share any sample code on when & how the graphicsOverlay being added?
Or
We have many samples adding graphics to graphicsOverlay, may be you can tweak one of those to showcase your workflow to reproduce the problem and share it here
https://github.com/Esri/arcgis-runtime-samples-android

Thanks
Rama

0 Kudos
JulianBissekkou
New Contributor III

Refreshing the viewpoint works as a workaround:

mapView.setViewpointScaleAsync(getMapScale(getZoomLevel(mapView)))

 

Here is some example code that I can share:

// When creating the view:
defaultGraphicsOverlay = GraphicsOverlay()
mapView.graphicsOverlays.add(defaultGraphicsOverlay)

// Method that adds the graphics:
private fun onAddGraphic() {
val newGraphics = createNewGraphics()
defaultGraphicsOverlay.graphics.addAll(newGraphics)
}


Its quiet simple. onAddGraphic is called at some point by the user, not initially.

0 Kudos