本文介绍了如何仅显示谷歌地图中的特定地区/地区为Android api v2 [Android]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何仅显示Google地图中的特定区域/区域以显示android api v2?所有功能必须在该区域可用,如缩放,拖动等。
所有其他区域必须裁剪掉或不可见。那可能吗???
我正在使用eclipse.help请
How to show only a specific region/area in google map for android api v2?.all functionalities must be available in that region like zooming,dragging etc.the all other areas must be cropped off or invisible. Is that possible???I am using eclipse.help me please
推荐答案
这个技巧适用于我
This trick worked for me
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
//get latlong for corners for specified place
LatLng one = new LatLng(27.700769, 85.300140);
LatLng two = new LatLng(27.800769, 85.400140);
LatLngBounds.Builder builder = new LatLngBounds.Builder();
//add them to builder
builder.include(one);
builder.include(two);
LatLngBounds bounds = builder.build();
//get width and height to current display screen
int width = getResources().getDisplayMetrics().widthPixels;
int height = getResources().getDisplayMetrics().heightPixels;
// 20% padding
int padding = (int) (width * 0.20);
//set latlong bounds
mMap.setLatLngBoundsForCameraTarget(bounds);
//move camera to fill the bound to screen
mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, width, height, padding));
//set zoom to level to current so that you won't be able to zoom out viz. move outside bounds
mMap.setMinZoomPreference(mMap.getCameraPosition().zoom);
}
这篇关于如何仅显示谷歌地图中的特定地区/地区为Android api v2 [Android]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!