3

所有基本的东西,我有一个 SupportMapFragment,一切正常,我只需要知道是否有一种让地图跟随我的位置的捷径,还是每次位置变化时我都必须移动相机?

4

2 回答 2

4

好吧,首先感谢您抽出时间 Naskov,但这不是 mapView,而是 MapFragment。我现在使用的代码(以防有人需要)是这个(onUpdateLocation)

    if (mapFragment.theMap != null) {
        CameraPosition cameraPosition = new CameraPosition.Builder()
                .target(new LatLng(getLocation().getLatitude(),
                        getLocation().getLongitude())).zoom(14.0f).build();
        CameraUpdate cameraUpdate = CameraUpdateFactory
                .newCameraPosition(cameraPosition);
        mapFragment.theMap.moveCamera(cameraUpdate);
    }

我只是想知道是否有一些内置的方法可以做到这一点,也因为这不是很顺利。如果有人想出更好的主意,请发布

于 2013-05-11T01:37:02.330 回答
2

这不完全是您想要的,但您可以使用:

map.setMyLocationEnabled(true);

在右上角的地图上添加一个按钮(就像在本地 Google 地图应用程序中一样),允许用户在需要时将相机位置更改为他的位置。

于 2013-05-11T03:43:52.893 回答