当地图处于加载状态时,我想在地图视图的中心放置一个进度条。
如何获得进度??怎么办??
给我举个例子。。
谢谢。
我认为没有任何合理的方法可以做到这一点。请注意,谷歌在他们的地图应用程序中也没有这样做。只需查看页面以查看图块是否仍在加载就很清楚了,所以我认为实际上不需要放入进度指示器。
MapView有一个方法canCoverCenter()
可以告诉您中心图块是否可用,但其余图块没有任何内容。
看看GoogleMap.OnMapLoadedCallback
地图完成渲染时的回调接口。这发生在获取渲染地图所需的所有图块并且所有标签都已完成之后。如果地图由于连接问题而永远不会加载,或者地图不断变化并且由于用户不断与地图交互而永远不会完成加载,则不会触发此事件。
使用示例:
/**
* Acquire a non-null instance of the GoogleMap.
*/
mMapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap googleMap) {
googleMap.setOnMapLoadedCallback(new OnMapLoadedCallback() {
/**
* Called when the map has finished rendering.
* This will only be called once.
* You must request another callback if you want to be notified again.
*/
@Override
public void onMapLoaded() {
//TODO: Hide ProgressBar
}
});
}
});