You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在谷歌地图应用中限制用户仅查看菲律宾锡基霍尔岛

Hey there! Let's tackle this problem step by step. You've got a single coordinate for Siquijor Island, but to restrict your Google Map to only show the island, you'll need to define a LatLngBounds that covers the entire island—just like the Adelaide example you shared.

How to Restrict Your Google Map to Siquijor Island

Step 1: Get Siquijor's Boundary Coordinates

The coordinate you have (9.1999° N, 123.5952° E) is the island's approximate center, but we need the southwest and northeast corner coordinates to create a proper bounds. Here are the approximate bounds for Siquijor (you can refine these by clicking the island's corners in Google Maps to get exact coordinates):

  • Southwest corner: LatLng(9.1138, 123.5142)
  • Northeast corner: LatLng(9.2862, 123.6758)

Step 2: Create the LatLngBounds Object

Follow the same pattern as the Adelaide example to define your private bounds object:

// Create LatLngBounds covering Siquijor Island
private LatLngBounds SIQUIJOR = new LatLngBounds(
    new LatLng(9.1138, 123.5142), // Southwest corner
    new LatLng(9.2862, 123.6758)  // Northeast corner
);

Step 3: Apply the Bounds to Your mMap Instance

Now you can use this bounds to lock the map to Siquijor in two key ways:

  1. Set the initial camera view to fit the island:
// Add padding (in pixels) to avoid cutting off UI elements like action bars
int padding = 50; 
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(SIQUIJOR, padding);
mMap.moveCamera(cameraUpdate);
  1. Prevent users from panning/zooming outside the island:
// Restrict all camera movement to stay within Siquijor's bounds
mMap.setLatLngBoundsForCameraTarget(SIQUIJOR);

Pro Tip for Better Precision

If you need ultra-accurate bounds:

  • Open Google Maps, navigate to Siquijor, right-click the island's extreme corners to copy their exact coordinates.
  • Use a tool like OpenStreetMap to extract the island's polygon boundaries, then calculate the minimum/maximum latitudes and longitudes to form your bounds.

内容的提问来源于stack exchange,提问作者Exc3m1206

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 07:52:57