3 回答
TA贡献1818条经验 获得超8个赞
Google Map V2
以下解决方案适用于Android Marshmallow 6(API 23,API 24,API 25,API 26,API 27,API 28)。它也可以在Xamarin中使用。
LatLngBounds.Builder builder = new LatLngBounds.Builder();
//the include method will calculate the min and max bound.
builder.include(marker1.getPosition());
builder.include(marker2.getPosition());
builder.include(marker3.getPosition());
builder.include(marker4.getPosition());
LatLngBounds bounds = builder.build();
int width = getResources().getDisplayMetrics().widthPixels;
int height = getResources().getDisplayMetrics().heightPixels;
int padding = (int) (width * 0.10); // offset from edges of the map 10% of screen
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, width, height, padding);
mMap.animateCamera(cu);
- 3 回答
- 0 关注
- 419 浏览
添加回答
举报