相机更新后停止平移到我的位置

stop panning to my location after camera update

我设置了一张地图,上面标有点,效果很好。我打开地图并移动和缩放到我的位置。问题是,当我从我的位置平移时,片刻之后它会带我回到我的位置。你怎么移动缩放然后在我的位置释放移动。

这里是移动和缩放的代码:

private void setUpMapIfNeeded() {
    // Do a null check to confirm that we have not already instantiated the map.
    if (mMap == null) {
        // Try to obtain the map from the SupportMapFragment.
        mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
                .getMap();

        mMap.setMyLocationEnabled(true);
        // Check if we were successful in obtaining the map.
        if (mMap != null) {
            setUpMap();

            mMap.setOnMyLocationChangeListener(new GoogleMap.OnMyLocationChangeListener() {

                @Override
                public void onMyLocationChange(Location arg0) {
                    // TODO Auto-generated method stub

                    LatLng myLocation =  new LatLng(arg0.getLatitude(),
                            arg0.getLongitude());
                    mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
                    CameraUpdate update = CameraUpdateFactory.newLatLngZoom(myLocation, 11);
                    mMap.moveCamera(update);
                    mMap.addMarker(new MarkerOptions()
                            .position(myLocation)
                            .title("Brian is Here!"));

                }
            });
        }
    }
}

我觉得这很容易,但我找不到答案。

如有任何帮助,我们将不胜感激。

你可以"easily"解决,如果你想在每次更改时都去你的位置,代码是正确的,如果你不想,问题是在位置更改时相机更改。

您只需按原样设置位置侦听器即可完成一次,然后在动画结束时移除侦听器。这将第一次 运行 动画,然后,由于侦听器被删除,将避免再次移动到该位置。