我想将点数转换为经度和纬度,如下面的代码我指出:
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 :(得分: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());
}
}
谢谢......