如何将Android esri arcGIS Point转换为经度和纬度
问题描述:
我想要通过Android esri arcGIS MapView获取纬度和经度。如何将Android esri arcGIS Point转换为经度和纬度
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)的纬度经度坐标?
答
最简单的方法是:
Point p=map.toMapPoint(arg0, arg1);
System.out.println("X="+p.getX());
System.out.println("Y="+p.getY());
变量p将在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);
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
答
如果要转换地图点为纬度/长,你只需要按照这个
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()
会给经度
如果我使用此代码,我没有得到确切的经度和纬度值。 – NandaKumar
如果你想使用WGS84,给你经纬度,你需要做一个投影你的观点。例如:'SpatialReference sp = SpatialReference.create(/ * spatial number * /); \t \t点AUX =(点)GeometryEngine.project(P, \t \t \t \t map.getSpatialReference(),SP);'。您可以在http://spatialreference.org/ –
搜索您的空间参考感谢,曼努埃尔皮雷斯我得到答案 – NandaKumar