I have a mapview in my app. My requirement开发者_如何学编程 is each time when I scroll through the map, I have to fetch the current center point of the map. How can I achieve it?
Documentation
getMapCenter()
First get a projection for converting between screen-pixel coordinates and latitude/longitude coordinates.
Projection P = mapview.getProjection();
Now you need to find the height and width of the screen in pixels and divide each by two which will given you the pixel coordinates of the center of the screen.
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
GeoPoint G = P.fromPixels(metrics.heightPixels/2, metrics.widthPixels/2);
G is the GeoPoint of the center of your present screen.
精彩评论