您应该使用CameraUpdate类来(可能)进行所有程序化地图移动。
为此,首先像这样计算所有标记的边界:
LatLngBounds.Builder builder = new LatLngBounds.Builder();for each (Marker m : markers) { builder.include(m.getPosition());}LatLngBounds bounds = builder.build();
然后通过使用工厂获取运动描述对象:CameraUpdateFactory:
int padding = 0; // offset from edges of the map in pixelsCameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);
最后移动地图:
googleMap.moveCamera(cu);
或者,如果您想要动画:
googleMap.animateCamera(cu);
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)