1

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

Shailendra Madda
  • 20,649
  • 15
  • 100
  • 138

1 Answers1

1

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/

Sneha Mudhigonda
  • 146
  • 2
  • 10