我想在Google地图中显示多个标记,并在单个视图中显示它们。我在地图上显示了所有标记但我在使用CameraUpdate时遇到了困难。请帮忙。提前谢谢。
答案 0 :(得分:1)
您必须创建一个LatLngBounds:
List<Marker> myMarkers; //your list of markers
LatLngBounds.Builder builder = new LatLngBounds.Builder();
for(Marker m: myMarkers){
builder.include(m.getPosition());
}
LatLngBounds bounds = builder.build();
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, 20);//20 is padding, use it to avoid markers on the border of the map view
mMap.animateCamera(cu);