2014-09-29 144 views
1

我想转换点经度和纬度,为下面的代码我有一点:如何在arcgis android中将点转换为经度和纬度?

mMapView.setOnSingleTapListener(new OnSingleTapListener() { 


       @Override 
       public void onSingleTap(float x, float y) { 


        callout.hide(); 

        int[] graphicIDs = graphicsLayer.getGraphicIDs(x, y, 25); 
        if (graphicIDs != null && graphicIDs.length > 0) { 
         Graphic gr = graphicsLayer.getGraphic(graphicIDs[0]); 
         updateContent((String) gr.getAttributeValue("Rating"), 
           (String) gr.getAttributeValue("Title")); 
         Point location = (Point) gr.getGeometry(); 
         callout.setOffset(0, -15); 
         callout.show(location, content); 


        } 

       } 

我有这个变量location如何找出经度和纬度,我已经改变了经度和纬度点为如下:

double mercatorX = longtitude* 0.017453292519943295 * 6378137.0; 
double a = latitude * 0.017453292519943295; 
double mercatorY = 3189068.5 * Math.log((1.0 + Math.sin(a)) 
     /(1.0 - Math.sin(a))); 

请我需要您的评论...

+0

然后做逆。当你是一名程序员时,数学并不难;) – 2014-09-29 17:26:08

+0

我的大脑现在不能工作;),如果可以的话,请尽量帮助我? – ROR 2014-09-29 17:28:08

回答

1

我发现它GUYS

 mMapView.setOnSingleTapListener(new OnSingleTapListener() { 


      @Override 
      public void onSingleTap(float x, float y) { 

       //Message.message(getApplicationContext(), "showLayer"+x +":"+y); 
       callout.hide(); 



       int[] graphicIDs = graphicsLayer.getGraphicIDs(x, y, 25); 
       if (graphicIDs != null && graphicIDs.length > 0) { 
        Graphic gr = graphicsLayer.getGraphic(graphicIDs[0]); 
        updateContent((String) gr.getAttributeValue("Rating"), 
          (String) gr.getAttributeValue("Title")); 
        Point location = (Point) gr.getGeometry(); 
        callout.setOffset(0, -15); 
        callout.show(location, content); 
        callout.setContent(content); 


        Log.e("EROR", location+""); 


        SpatialReference sp = SpatialReference.create(SpatialReference.WKID_WGS84); 
        Point aux = (Point) GeometryEngine.project(location, mMapView.getSpatialReference(), sp); 

        Log.e("L","latitude="+aux.getX()); 
        Log.e("L","longitude="+aux.getY()); 


       } 

      } 

这是位置可变的,但如果有人想知道X和Y, 你可以这样做:

mMapView.setOnSingleTapListener(new OnSingleTapListener() { 


      @Override 
      public void onSingleTap(float x, float y) { 

       //Message.message(getApplicationContext(), "showLayer"+x +":"+y); 
       callout.hide(); 



       int[] graphicIDs = graphicsLayer.getGraphicIDs(x, y, 25); 
       if (graphicIDs != null && graphicIDs.length > 0) { 
        Graphic gr = graphicsLayer.getGraphic(graphicIDs[0]); 
        updateContent((String) gr.getAttributeValue("Rating"), 
          (String) gr.getAttributeValue("Title")); 
        Point location = (Point) gr.getGeometry(); 
        callout.setOffset(0, -15); 
        callout.show(location, content); 
        callout.setContent(content); 


        Log.e("EROR", location+""); 

        Point p=mMapView.toMapPoint(x,y); 
        SpatialReference sp = SpatialReference.create(SpatialReference.WKID_WGS84); 
        Point aux = (Point) GeometryEngine.project(location, mMapView.getSpatialReference(), sp); 

        Log.e("L","latitude="+aux.getX()); 
        Log.e("L","longitude="+aux.getY()); 


       } 

      } 

感谢...