我在我的 android 应用程序中包含了 Open Street Maps。在地图视图中,用户应该能够在地图完全加载后捕获屏幕。但是目前即使地图视图仍在加载,用户也可以捕获图像。有人能告诉我如何检测地图视图何时完全加载吗?
下面是我加载地图视图的代码:
public class MainActivity extends Activity {
MapView mapView;
MyLocationOverlay myLocationOverlay = null;
ArrayList<OverlayItem> anotherOverlayItemArray;
protected ItemizedOverlayWithBubble<ExtendedOverlayItem> itineraryMarkers;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapView = (MapView) findViewById(R.id.mapview);
final ArrayList<ExtendedOverlayItem> waypointsItems = new ArrayList<ExtendedOverlayItem>();
itineraryMarkers = new ItemizedOverlayWithBubble<ExtendedOverlayItem>(this, waypointsItems, mapView, new ViaPointInfoWindow(R.layout.itinerary_bubble, mapView));
mapView.getOverlays().add(itineraryMarkers);
mapView.setTileSource(TileSourceFactory.MAPNIK);
mapView.setBuiltInZoomControls(true);
MapController mapController = mapView.getController();
mapController.setZoom(1);
GeoPoint point2 = new GeoPoint(51496994, -134733);
mapController.setCenter(point2);
Drawable marker=getResources().getDrawable(android.R.drawable.star_big_on);
GeoPoint myPoint1 = new GeoPoint(0*1000000, 0*1000000);
ExtendedOverlayItem overlayItem = new ExtendedOverlayItem("Title Test Loc", "Desc", myPoint1, this);
overlayItem.setMarkerHotspot(OverlayItem.HotspotPlace.BOTTOM_CENTER);
overlayItem.setMarker(marker);
overlayItem.setRelatedObject(0);
itineraryMarkers.addItem(overlayItem);
mapView.invalidate();
myLocationOverlay = new MyLocationOverlay(this, mapView);
mapView.getOverlays().add(myLocationOverlay);
myLocationOverlay.enableMyLocation();
myLocationOverlay.runOnFirstFix(new Runnable() {
public void run() {
mapView.getController().animateTo(myLocationOverlay.getMyLocation());
}
});
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
myLocationOverlay.enableMyLocation();
myLocationOverlay.enableCompass();
myLocationOverlay.enableFollowLocation();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
myLocationOverlay.disableMyLocation();
myLocationOverlay.disableCompass();
myLocationOverlay.disableFollowLocation();
}