如何在arcgis android中将点转换为经度和纬度?
我想将点转换为经度和纬度,如下代码所示:如何在arcgis android中将点转换为经度和纬度?,android,map,arcgis,Android,Map,Arcgis,我想将点转换为经度和纬度,如下代码所示: mMapView.setOnSingleTapListener(new OnSingleTapListener() { @Override public void onSingleTap(float x, float y) { callout.hide(); int[] graphicIDs = gra
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());
}
}
谢谢…然后做相反的事情。当你是一名程序员时,数学并没有那么难;)我的脑子现在不工作了;),如果可以的话,请帮我一下好吗?