how get the progress status of loading mapview in android?

随声附和 提交于 2019-12-01 06:51:43

I don't think there is any reasonable way of doing it. Note that Google isn't doing this either in their map applications. It is pretty clear just looking at the page to see if tiles are still loading, so I don't think there is actually any need to put in a progress indicator.

The MapView has a method canCoverCenter() which can tell you if the center tile is available, but there is nothing for the rest of the tiles.

Take a look at GoogleMap.OnMapLoadedCallback

Callback interface for when the map has finished rendering. This occurs after all tiles required to render the map have been fetched, and all labeling is complete. This event will not fire if the map never loads due to connectivity issues, or if the map is continuously changing and never completes loading due to the user constantly interacting with the map.

Usage example:

/**
 * 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
            }
        });
    }
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!