android - 如何在arcgis android中将点转换为经度和纬度?

标签 android dictionary arcgis

我想将点转换为经度和纬度,如下代码我有点:

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)));

我需要你的评论...

最佳答案

我找到了伙计们

       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());


                }

            }

谢谢...

关于android - 如何在arcgis android中将点转换为经度和纬度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26105453/

相关文章:

android - 如何将 OnActivityResult() 方法用于 ProgressBar 的 setMax() 方法

java - 如何在 eclipse/Android 中使用 --core-library 选项

swift - 我在整合字典中的数据时遇到问题

javascript - 如何使用 ArcGIS JavaScript API 直接绘制点和文本

javascript - ESRI/ArcGIS : "Error: Services Directory has been disabled."

Android Kotlin 按整理器排序

JavaScript Promise.all 代码未按预期工作

python - 从字典列表中删除具有重复值的字典

javascript - 使用 jquery/javascript 通过 Rest 和 json 编辑 ArcGIS 服务中的数据

android - SearchView AppCompatActivity 中的空指针?