首页 > 解决方案 > Android ESRI地图如何从屏幕点获取纬度经度

问题描述

我知道我们可以screenPoint使用这个从 ESRI 地图上的触摸位置获取

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

我们也可以mapPointscreenPoint使用这个

val mapPoint = mapView?.screenToLocation(screenPoint)

现在我如何从这些screenPointmapPoint

标签: esri-mapsarcgis-android-api

解决方案


你可以得到CoordinateFormatter如下

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

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


推荐阅读