2013-04-18 65 views
0

我想要通過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)的緯度經度座標?

回答

3

最簡單的方法是:

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

變量p將在MapView的映射座標。

+0

如果我使用此代碼,我沒有得到確切的經度和緯度值。 – NandaKumar

+0

如果你想使用WGS84,給你經緯度,你需要做一個投影你的觀點。例如:'SpatialReference sp = SpatialReference.create(/ * spatial number * /); \t \t點AUX =(點)GeometryEngine.project(P, \t \t \t \t map.getSpatialReference(),SP);'。您可以在http://spatialreference.org/ –

+0

搜索您的空間參考感謝,曼努埃爾皮雷斯我得到答案 – NandaKumar

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

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()會給經度