【问题标题】:Avoid Map Zoom Out Automatically android避免地图自动缩小android
【发布时间】:2019-01-24 10:55:53
【问题描述】:

我在安卓中使用地图。这是我的 OnLocationChanged 方法,我的应用程序工作正常,但我正在缩放我的地图,它会在几秒钟后自动缩小……我在我的方法中使用上述 MoveCamera。我在 Android Studio 中使用 MapsActivity 默认值。

public void onLocationChanged(Location location) {
        mCurrentLocation = location;
        if (mCurrLocationMarker != null) {
            mCurrLocationMarker.remove();
            //Toast.makeText(context, "Location Not Found.", Toast.LENGTH_SHORT).show();
        }

        //Place current location marker
        LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
        MarkerOptions markerOptions = new MarkerOptions();
        markerOptions.position(latLng);
        markerOptions.title("Current Position");
        markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_MAGENTA));
        mCurrLocationMarker = mMap.addMarker(markerOptions);


        mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 12));


    }

【问题讨论】:

  • 首先,试着理解你在代码中写了什么

标签: android google-maps dictionary


【解决方案1】:

您的地图不会自动缩小。它缩小了,因为你为它写了代码

mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 12));

这在每次 onLocationChanged 和缩放时都有效。如果您想将相机移动到新位置但不想缩放,可以尝试 CameraUpdateFactory 的 newLatLngBounds 功能

【讨论】:

  • 提供任何链接。
猜你喜欢
  • 1970-01-01
  • 2020-07-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-04-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多