Select to view content in your preferred language

LocationDisplay.location and mapLocation returning different points

359
3
04-16-2024 09:23 AM
HVN
by
New Contributor II

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.

Tags (2)
0 Kudos
3 Replies
Shubham_Sharma
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
BertrandLAURANCIN
Esri Contributor

Hello @Shubham_Sharma,

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

Thank you,
Regards,
Bertrand

 

0 Kudos
BertrandLAURANCIN
Esri Contributor

Hello,

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