1

我正在尝试通过 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

4 回答 4

3

最简单的方法是:

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

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

于 2013-05-21T12:15:09.827 回答
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()并将给出经度

于 2015-12-16T15:41:47.377 回答
1

我厌倦了 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
于 2019-06-24T09:32:29.843 回答
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

于 2013-06-18T08:59:26.097 回答