I want to convert point to longtitude and latitude , as a below code I have point :
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);
}
}
I have this variable location
how to find out the longtitude and latitude , I already changed the longtitude and latitude to point as a below :
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)));
please i need your comment ...
I found it 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());
}
}
this is for location variable but if someone want to know X and Y, you can do this :
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());
}
}
thanks ...