Closed GoogleCodeExporter closed 9 years ago
To duplicate:
Take the stock OpenStreetMapViewer project and do the following:
MapActivity.java - add
@Override
public boolean onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
Log.d("mapactivity", "touchevent");
Log.d("mapactivity", "Map x/y" + event.getX() + " / " + event.getY());
MapFragment mapFragment = (MapFragment) this.getSupportFragmentManager().findFragmentById(R.id.map_container);
if (mapFragment != null) {
GeoPoint p = mapFragment.toLatLon(event.getX(), event.getY());
Log.d("mapactivity", "Lat/lon - " + p.getLatitude() + p.getLongitude());
}
return super.onTouchEvent(event);
}
MapFragment.java, add:
public GeoPoint toLatLon(float x, float y) {
return (GeoPoint) mMapView.getProjection().fromPixels(x, y);
}
public Point fromLatLon(GeoPoint p) {
return mMapView.getProjection().toMapPixels(p, null);
}
Then launch the app.
Zoom to continental US, touch "Washington DC"
Get a Logcat saying "11-13 12:43:19.171: D/mapactivity(24255): Lat/lon -
36.244273 -77.124023"
Overflow menu, and enable rotation.
Rotate map ~45 degrees
Tap Washington DC again, logcat says "11-13 12:44:35.581: D/mapactivity(24255):
Lat/lon - 34.597041-80.112304"
Lat/lon returned from the projection functions doesn't correct for the rotation.
(Sorry that I don't quite have the math/time on hand to dig into what is needed
to correct this and offer a patch)
Original comment by nathan.t...@gmail.com
on 13 Nov 2013 at 5:46
Updates in 499 may fix this issue once complete.
Original comment by kurtzm...@gmail.com
on 10 Dec 2013 at 9:44
[deleted comment]
Fixed in Github.
Original comment by kurtzm...@gmail.com
on 16 Apr 2014 at 10:28
Original issue reported on code.google.com by
nathan.t...@gmail.com
on 12 Nov 2013 at 8:51