On version 200.4 of the SDK.
Issue
According to the API reference, these two attributes should return the same position with the later getting projected to the map view projection. In effect, this does not seem to be the case and the attributes "mapLocation" retains the first position received from the dataSource while "location" correctly gets updated.
@HVN Thanks for bringing this up, it seems like there is a bug with LocationDisplay.mapLocation not updating after the first location update. We have logged this and will provide a fix in the next release.
You could instead retrieve the location from the LocationDisplay.location Stateflow, collect the location changes and convert the given location to MapView's projection using GeometryEngine. Essentially, giving you the same value as the "mapLocation".
// start the location data source...
lifecycleScope.launch {
locationDisplay.location.filterNotNull().collect { location ->
// Get the map location using the same projection as the MapView
val mapLocation = GeometryEngine.projectOrNull(
geometry = location.position,
spatialReference = mapView.spatialReference.value ?: SpatialReference.webMercator()
)
}
}
Hello @Shubham_Sharma,
Do you know the reference of the bug please ? I cannot find it.
Thank you,
Regards,
Bertrand
Hello,
For information :
BUG-000167296 : ArcGIS Maps SDK for Kotlin - locationDisplay.location updates as expected when device changes location whereas locationDisplay.mapLocation does not