显示 "indeterminate progress bar" 直到我的位置显示在地图上

Display an "indeterminate progress bar" until my location is shown on the map

我正在使用带有地图 v2 的 onMyLocationChangeLIstener。 它完美运行:

 private void setUpMap() {

 GoogleMap.OnMyLocationChangeListener myLocationChangeListener = new GoogleMap.OnMyLocationChangeListener() {
                @Override
                public void onMyLocationChange(Location location) {
                    LatLng loc = new LatLng(location.getLatitude(), location.getLongitude());

                    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(loc, 16.0f));

            };

            mMap.setOnMyLocationChangeListener(myLocationChangeListener);
 }

activity启动时,会显示整个地图,当系统找到我的位置时,会在地图上显示缩放标记。

我想显示 "indeterminate progress bar" 从 activity 开始,直到它显示我的位置。

我一直在阅读它,但我找到了一种方法。

感谢任何帮助。

感谢和问候。

在地图片段之上放置一个视图怎么样?您可以使用 FrameLayout 暂时(否则不利于渲染)将视图与不确定的进度重叠。当您收到位置更改(您的侦听器)时,您可以检查框架布局是否显示(如果存在),如果显示,则将其删除。

通常 google 准则不建议这样做,因为检索位置可能需要几分钟到几小时(在室内甚至找不到)。