【问题标题】:How to restrict user's view only to an island in a country?如何将用户的视图限制在一个国家的一个岛屿上?
【发布时间】:2018-04-05 00:35:32
【问题描述】:

我的项目是为游客制作一个菲律宾锡基霍尔岛的地图应用程序,我希望该应用程序只显示该岛。我能找到的唯一坐标是9.1999° N, 123.5952° E。我不知道如何实现这些坐标

private GoogleMap mMap;
// Create a LatLngBounds that includes the city of Adelaide in Australia.
private LatLngBounds ADELAIDE = new LatLngBounds(
  new LatLng(-35.0, 138.58), new LatLng(-34.9, 138.61));
// Constrain the camera target to the Adelaide bounds.
mMap.setLatLngBoundsForCameraTarget(ADELAIDE);

【问题讨论】:

标签: android google-maps android-studio-3.0


【解决方案1】:

LatLngBounds class reference

相关信息:

LatLngBounds(LatLng southwest, LatLng northeast)
Creates a new bounds based on a southwest and a northeast corner.

所以,第一个参数是边界的西南角,第二个参数是边界的东北角。

因此,您可以转到Google Maps 并找到您希望地图边界的区域的西南和东北坐标。点击地图可以查看您刚才点击的点的坐标。

此外,请查看Google Maps Gestures 以及如何启用/禁用它们,以进一步控制其他人如何导航您的地图。

例如禁用某些手势:

 public void onMapReady(GoogleMap map) {
    UiSettings uiSettings = map.getUiSettings();
    uiSettings.setZoomGesturesEnabled(false); //disable zoom gestures
    uiSettings.setScrollGesturesEnabled(false); //disable scroll(pan) gestures
    uiSettings.setTiltGesturesEnabled(false); //disable tilt gestures
    uiSettings.setRotateGesturesEnabled(false); //disable rotation gestures

}

【讨论】:

  • 虽然此链接可能会回答问题,但最好在此处包含答案的基本部分并提供链接以供参考。如果链接页面发生更改,仅链接答案可能会失效。 - From Review
  • 谢谢,@AsifAli72090。我已经更新了我的答案,以从引用的链接中添加相关信息。
猜你喜欢
  • 2020-05-24
  • 1970-01-01
  • 2016-08-04
  • 1970-01-01
  • 1970-01-01
  • 2021-08-05
  • 1970-01-01
  • 1970-01-01
  • 2013-08-01
相关资源
最近更新 更多