如何将Android esri arcGIS Point转换为经度和纬度

时间:2013-04-18 12:48:30

标签: android arcgis

我正试图通过Android esri arcGIS MapView获取点击的纬度和经度。

        map.setOnSingleTapListener(new OnSingleTapListener() {

            private static final long serialVersionUID = 1L;

            public void onSingleTap(float x, float y) {
                System.out.println("x:" + x);
                System.out.println("y:" + y);
                // How to get Latitude Longitude coordinates of the point (x,y)?

            }
        });

如何获得点(x,y)的纬度经度坐标?

4 个答案:

答案 0 :(得分:3)

最简单的方法是:

Point p=map.toMapPoint(arg0, arg1);
System.out.println("X="+p.getX());
System.out.println("Y="+p.getY());

变量p将在MapView中映射坐标。

答案 1 :(得分:1)

如果您想将地图点转换为纬度/经度,您只需按照此

即可
Point mapPoint = mMapView.toMapPoint(point.getX(), point.getY());
//Here point is your MotionEvent point
SpatialReference spacRef = SpatialReference.create(4326);
//4326 is for Geographic coordinate systems (GCSs) 
Point ltLn = (Point)
GeometryEngine.project(mapPoint,mMapView.getSpatialReference(), spacRef ); 
//mMapView is your current mapview object

ltLn.getY()将给出纬度,ltLn.getX()将给出经度

答案 2 :(得分:0)

map.setOnSingleTapListener(new OnSingleTapListener() {

            private static final long serialVersionUID = 1L;

            public void onSingleTap(float x, float y) {
                System.out.println("x:" + x);
                System.out.println("y:" + y);


Point p=map.toMapPoint(x,y );

 SpatialReference sp = SpatialReference.create(/*spatial number*/);
 Point aux = (Point) GeometryEngine.project(p, map.getSpatialReference(), sp);

System.out.println("latitude="+aux.getX());
System.out.println("longitude="+aux.getY());

            }
        });

表示空间编号spatialreference.org

答案 3 :(得分:0)

我对Kotlin中的此解决方案及其预期的工作感到厌倦

       val sp = SpatialReference.create(4326)
       // where Location is the Point
       val locationPoint = GeometryEngine.project(location, sp) as Point
       val lat = locationPoint.x
       val lng = locationPoint.y