Select to view content in your preferred language

LocationDisplay.location and mapLocation returning different points

04-16-2024 09:23 AM
New Contributor II

On version 200.4 of the SDK.


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.

Tags (2)
0 Kudos
3 Replies
Esri Contributor

@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()


0 Kudos
Esri Contributor

Hello @Shubham_Sharma,

Do you know the reference of the bug please ? I cannot find it.

Thank you,


0 Kudos
Esri Contributor


For information :

BUG-000167296 : ArcGIS Maps SDK for Kotlin - locationDisplay.location updates as expected when device changes location whereas locationDisplay.mapLocation does not


0 Kudos