gpt4 book ai didi

android - 检测 OSM Mapview 是否仍在加载或不在 android 中

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:00:33 24 4
gpt4 key购买 nike

我在我的 Android 应用程序中包含了 Open Street Maps。在 map View 中,用户应该能够在 map 完全加载后捕获屏幕。但目前即使 map View 仍在加载,用户也可以捕获图像。谁能告诉我如何检测 map View 何时完全加载?

下面是我加载 map View 的代码:

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();
}

最佳答案

看看 TilesOverlayTileLooper 实现。这就是我们用来加载然后在屏幕上绘制每个图 block 的方法。在 handleTile(...) 中,我们尝试从图 block 提供程序 mTileProvider.getMapTile(pTile) 获取图 block 。如果返回 Drawable,则加载图 block ,否则将返回 null

一个简单的方法是扩展 TilesOverlay,覆盖 drawTiles(...) 并在调用之前调用您自己的 TileLooper super.drawTiles(...) 将检查是否所有传递给 handleTile(...) 的图 block 都不为空。要使用您的 TilesOverlay,请调用 mMapView.getOverlayManager().setTilesOverlay(myTilesOverlay)

关于android - 检测 OSM Mapview 是否仍在加载或不在 android 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17079359/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com