Map View takes too long to pan to users location on second opening

399
0
06-26-2023 04:25 AM
João_Mendes
New Contributor II

Using:
Arcgis Maps SDK for Kotlin - 200.1 - April 19, 2023

I mainly followed the samples for 200.1, when first opening the activity containing the MapView it runs well, requests the user location and when granted pans to the user location. When the user leaves the activity and reopens  it the map is zoomed out to the max extent (world map) and takes around 5 secs to retrieve the user's location and pan to it.
However this doesn't happen everytime, but most of the time. The first time running the activity is always fine.

This is mainly problematic because the user may start panning around and then the MapView won't pan to their location automatically. Also I dind't find a way to check when the Map View finished panning to the user's location so that I could add a loading overlay.

I've tried it  on 3 different devices (Samsung, Xiaomi and ZTE) and always get the same result.

I'll leave below an attachment.

Heres my setupMap funtion:

private fun setupMap() {
// create a map with the BasemapStyle Topographic
val map = ArcGISMap(BasemapStyle.ArcGISTopographic)

// set the map to be displayed in the layout's MapView
mapView.map = map

// LocationProvider requires an Android Context to properly interact with Android system
ArcGISEnvironment.applicationContext = applicationContext
// set the autoPanMode
locationDisplay.setAutoPanMode(LocationDisplayAutoPanMode.Recenter)

lifecycleScope.launch {
// start the map view's location display
locationDisplay.dataSource.start()
.onFailure {
// check permissions to see if failure may be due to lack of permissions
requestPermissions()
mapView.setViewpoint(
Viewpoint(
defaultViewLat,
defaultViewLong,
defaultViewScale
)
)
}
.onSuccess {
locationDisplay.setAutoPanMode(LocationDisplayAutoPanMode.Recenter)
}
}
}

And here's my onCreate function:

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_occ_create_info)

...

lifecycle.addObserver(mapView)

setApiKey()

setupMap()

...
}

 

0 Kudos
0 Replies