微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Android ESRI地图如何从屏幕点获取纬度经度

如何解决Android ESRI地图如何从屏幕点获取纬度经度

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

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

我们也可以使用此方法mapPoint中获得screenPoint

val mapPoint = mapView?.screenToLocation(screenPoint)

现在如何从这些screenPointmapPoint中获得经纬度

解决方法

您可以按以下方式获取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/

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。