I use the maps forge 0.5.1 libraries (api reference) I have followed all the official instructions but I have the following problem :
I have attached an onTouchListener on the
(org.mapsforge.map.android.view.MapView)mapView
but when I try to call the method mapView.getProjection(), I get the error "Cannot resolve the method getProjection(). Even if the method is getting called in many online examples,there is not in the official api reference or in MapView.class. org.mapsforge.map.android.view.MapView
org.mapsforge.map.android.view.MapView mapView;
mapView.setOnTouchListener(new View.OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent ev) {
int actionType = ev.getAction();
switch (actionType) {
case MotionEvent.ACTION_DOWN:
return false;
case MotionEvent.ACTION_UP:
mapView.getProjection(); // the error is here
return true;
case MotionEvent.ACTION_MOVE:
return false;
}
return false;
}
});
Is there any alternative way to get the latitude and longitude of the tapped point using mapsforge lib? Am I doing something wrong? If there is no way to get the coordinates after a tap, I thing that the library is missing something very important.
Thank you
Use
new MapViewProjection(mapView).fromPixels(double x, double y);
THey reversed the linkage in version 0.4 or so- now instead of getting the projection from a mapview, you pass a mapview to a projection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With