I use an extended class of MapView and I want to modify the interactions with the user.
public boolean onTouchEvent(MotionEvent motionEvent) {
float x = motionEvent.getX();
float y = motionEvent.getY();
byte zoomLevel = this.getMapPosition().getZoomLevel();
return true;
}
For example I get X : 804.3716, Y : 344.0, Zoom : 13
And now I want to get the geographic coordinates (the mercator point). I try to use the class MercatorProjection in org.mapsforge.core but It seems that it’s not the right solution …
Hello, I use Mapsforge, but I found the solution.
You may use the class Projection like this :
long x = motionEvent.getX();
long y = motionEvent.getY();
byte zoomLevel = this.getMapPosition().getZoomLevel();
Projection p = this.getProjection();
GeoPoint g = p.fromPixels((int)x,(int)y);
double latitude = g.getLatitude();
double longitude = g.getLongitude();
Log.v("Projection", "Coordonnées : " + latitude + " " + longitude);