I would like to convert GeoPoint to a screen point to identify all objects above the touch event. So, I tried this:
Projection projection = this.mapView.getProjection(); GeoPoint gie = new GeoPoint(lat, lon); Point po = new Point(); projection.toPixels(gie, po);
But po.x and po.y are not screen coordinates, but the display coordinates in pixels instead of lat, lon.
On the Android developer website:
toPixels (GeoPoint in, android.graphics.Point out) Converts GeoPoint data to the coordinates of the screen pixel relative to the upper left corner of the MapView that provided this projection.
So, is it possible to convert it to the correct screen coordinates?
I want to know all x GeoPoint that are next to the touch + event, as in the above example:
---------------------------------------------------------------- (0,0) -----------> x | | | | | | | <-- My screen | + (touch event) | \/ x (my GeoPoint) | y | | ----------------------------------------------------------------
I get a touch event as follows:
@Override public boolean onTouchEvent(MotionEvent event) { float x = event.getX(); float y = event.getY();
Here, in this code, x and y are the real screen coordinates (hardware, not cards)
I know that I can also convert the x, y coordinates to GeoPoint to compare them with my GeoPoint, but due to the zoom level I cannot get what I want.