You can achieve your goal by getting the map coordinates from the top-left and bottom-right angles and divide it by the screen size to get the value per pixel.
Then you just need to multiply by the offset and add it to the original center.
Code example:
private void centerMap(GeoPoint center, int offX, int offY){ GeoPoint tl = mapView.getProjection().fromPixels(0, 0); GeoPoint br = mapView.getProjection().fromPixels(mapView.getWidth(), mapView.getHeight()); int newLon = offX * (br.getLongitudeE6() - tl.getLongitudeE6()) / mapView.getWidth() + center.getLongitudeE6(); int newLat = offY * (br.getLatitudeE6() - tl.getLatitudeE6()) / mapView.getHeight() + center.getLatitudeE6(); mapController.setCenter(new GeoPoint(newLat, newLon)); }
For use, you call the method above with the original center and both offsets (x and Y) to apply.
Note: as indicated, the code above moves the map to the left for positive offset values ββand to the right for negative offset values. On the screen of your question, you will need to use a negative offset, move the map to the left and a zero offset for Y.
Hello
source share