I eventually answered the question on my own by adding the call to getMapCenter
in the draw method of an overlay.
public MyOverlay(TextView lblCoords) {
super();
coordinateLabel = lblCoords;
}
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
super.draw(canvas, mapView, shadow);
currentCenter = mapView.getMapCenter();
latitude = currentCenter.getLatitudeE6() / 1E6;
longitude = currentCenter.getLatitudeE6() / 1E6;
coordinateLabel.setText("lat: " + latitude + " long: " + longitude);
}
You can also extend the MapView
class and put the coordinate code in the onInterceptTouchEvent
method so it is updated only when the user moves the screen. This would be more efficient than putting it in an overlays onDraw, because onDraw is called constantly.