Dear Esri,
We are seeing an issue using the Kotlin SDK (currently at 200.8.0) on Samsung S24 phones where the map jumps around while on LocationDisplayAutoPanMode.Recenter (see the attached video). It might be on other phone models as well, but that model is confirmed.
Do you have any tips on what we could try to resolve this?
We have recently updated the app from the 100.x series, and did not see that issue before.
Here is our code which has mostly stayed the same apart from the obvious changes on how location display mode is activated using the Kotlin 200.x.
fun setLocationDisplayMode(view: MapView?, locationDisplayMode: String) {
val locationDisplay = mapView.locationDisplay
// OFF
try {
if (locationDisplayMode == "off") {
setAutoPanMode(locationDisplay, locationDisplayMode)
return
}
} catch (ex: Exception) {
Log.w(
LOG_CLASS,
"ERROR: Could not init and/or stop location display mode: " + ex.message
)
return
}
val status = locationDisplay.dataSource.status.value
// For mode transitions (not initial setup), set the mode directly if location is already active
if (status == LocationDataSourceStatus.Started) {
try {
setAutoPanMode(locationDisplay, locationDisplayMode)
return
} catch (ex: Exception) {
Log.w(LOG_CLASS, "ERROR: Could not set autopan mode directly: " + ex.message)
// Fall through to full initialization if direct mode setting fails
}
}
// Starting
if (status == LocationDataSourceStatus.Stopped || status == LocationDataSourceStatus.Stopping) {
try {
managerScope.launch {
locationDisplay.dataSource.start()
}
setAutoPanMode(locationDisplay, locationDisplayMode)
} catch (ex: Exception) {
Log.w(LOG_CLASS, "ERROR: Could not start locationDisplay: " + ex.message)
}
}
}
private fun setAutoPanMode(locationDisplay: LocationDisplay, locationDisplayMode: String) {
try {
when (locationDisplayMode) {
"autoPanRecenter" -> {
locationDisplay.setAutoPanMode(LocationDisplayAutoPanMode.Recenter)
}
"compassNavigation" -> {
locationDisplay.setAutoPanMode(LocationDisplayAutoPanMode.CompassNavigation)
}
"off" -> {
locationDisplay.setAutoPanMode(LocationDisplayAutoPanMode.Off)
managerScope.launch {
locationDisplay.dataSource.stop()
}
}
}
} catch (ex: Exception) {
Log.w(LOG_CLASS, "ERROR: Could not set auto pan mode: " + ex.message)
throw ex
}
}
Just to note: It goes on like that forever, even while the user is moving around.
I have found the wanderer extent factor now so we can tune the behaviour a bit, but still a workaround.
where the map jumps around while on LocationDisplayAutoPanMode.Recenter
Curious to know more about the behavior here, your code looks right and the video helps suggest that the blue-dot is "moving" towards a new (invalid) location event, and then correct itself to a more valid location provided by the gnss of the device. With the help of auto-pan mode recenter, this maybe visually noticeable as it is panning the map to center towards each location event.
I would recommend inspecting and log the events provided by the LocationDisplay.dataSource like locationChanged, headingChanged, error, status to more understand the underlying behavior. Are these location changes any which way being reported by the data source? And if so, does it occur with specific devices or version or API level? This information would help us isolate the cause of the issue.
We've made a sample app demonstrating some other location data sources available.
A read through this blog could also help with getting location more stable in your app.
Thanks for the reply @Shubham_Sharma . I will check out your tips.
With the app in question observed the same behavior on my Samsung S25 and an older Android phone (Nokia XR20) as well. Putting the phone in flight mode eliminated the issue. From my experience the issue get worse when being a bit away from buildings (wifi is turned off).
I then tested Show Device Location in the ArcGIS Maps Kotlin Samples app and observed the exact same behavior there. I've attached a recording from the example app.