Android ESRI map how to get the latitude longitude from screen point

501 views Asked by At

I know we can get the screenPoint from the touched location on the ESRI map using this

val screenPoint = android.graphics.Point(motionEvent.x.roundToInt(), motionEvent.y.roundToInt())

And also we can get the mapPoint from the screenPoint using this

val mapPoint = mapView?.screenToLocation(screenPoint)

Now how do I get the latitude and longitude from these screenPoint or mapPoint

1

There are 1 answers

0
Sneha Mudhigonda On BEST ANSWER

You can get the CoordinateFormatter as below

val mapPoint = mapView?.screenToLocation(screenPoint)
            val toLatitudeLongitude = CoordinateFormatter.toLatitudeLongitude(mapPoint, CoordinateFormatter.LatitudeLongitudeFormat.DECIMAL_DEGREES, 4)
            val point = CoordinateFormatter.fromLatitudeLongitude(toLatitudeLongitude, spatialReference)
            val latitude = point.x
            val longitude = point.y

Reference: https://developers.arcgis.com/android/latest/java/sample-code/format-coordinates/