安卓; MapView,如何设置默认位置?

发布于 2024-09-17 01:27:54 字数 65 浏览 1 评论 0原文

使用android中的MapView,如何设置默认位置,以便每次加载此应用程序时,它都会自动将位置集中/缩放到伦敦?

Using the MapView in android, how can I set a default location, so that everytime I load up this application, it automatically centers/zooms location in on London?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月下伊人醉 2024-09-24 01:27:56

首先,获取给定地图的控制器:

MapController myMapController = myMapView.getController();

然后调用:

myMapController.setCenter(new GeoPoint())

这将在给定的 GeoPoint 上设置地图的中心。

请参阅 MapViewMapController 了解更多信息

Firstly, get the controller for the given map:

MapController myMapController = myMapView.getController();

and then call:

myMapController.setCenter(new GeoPoint())

This will set the center of the map on the given GeoPoint.

See docs for MapView and MapController for more info

忆梦 2024-09-24 01:27:56

对于新的 Google Maps API,您需要执行以下操作:

mapFragment.getMapAsync(this::setUpMaps);

setUpMaps(GoogleMap googleMap) 内,您应该将相机移动到默认位置:

googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(location, zoom));

For new Google Maps API you need to do this:

mapFragment.getMapAsync(this::setUpMaps);

And inside setUpMaps(GoogleMap googleMap) you should move camera to your default location:

googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(location, zoom));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文