在 google maps
我想把我的相机固定在一个特定的国家。我不需要整个世界 Mercator 投影。所以我需要设置 LatLngBounds
在我的谷歌地图。我怎样才能找到 LatLngBounds
我的代码是这样的,但它没有设定 LatLngBounds
作为我的期望集的限制在右侧。
LatLng v1= new LatLng(24.044982389517603,89.75482430309057);
LatLng v2 = new LatLng(22.309956868003045,91.20187237858772);
LatLngBounds BANGLADESH = new LatLngBounds(
v2,v1
);
mMap.setLatLngBoundsForCameraTarget(BANGLADESH);
你可以得到国家边界一次从 openstreetmap.org 如同 这个 条款 Pēteris Ņikiforovs. 或以 http:/polygons.openstreetmap.frget_poly.py?id=184640¶ms=0。 并将其添加为多边形点,找到 LatLngBounds
像你这样做。
...
Builder builder = new LatLngBounds.Builder();
for(int i = 0 ; i < N_POINTS; i++) {
builder.include(new LatLng(lat, lng));
}
LatLngBounds BANGLADESH = new LatLngBounds = builder.build();
int padding = 15; // offset from edges of the map in pixels
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(BANGLADESH, padding);
mMap.moveCamera(cameraUpdate );
...