Mapbox Android determine zoom level that contain all markers

前端 未结 2 1910
没有蜡笔的小新
没有蜡笔的小新 2021-02-19 13:33

Is there a way to determine a zoom level so that all of my markers can fit in the zoom level? i am using mapbox 0.4.0

I think the answer is similar to this, but I can\'t

2条回答
  •  隐瞒了意图╮
    2021-02-19 14:22

    With the latest SDK version the existing answer does not work anymore. Instead, use this:

    LatLngBounds latLngBounds = new LatLngBounds.Builder()
      .include(new LatLng()) 
      .include(new LatLng()) 
      .build();
    
    mapboxMap.moveCamera(CameraUpdateFactory.newLatLngBounds(latLngBounds, 50));
    

    Thanks to the friendly Mapbox support for providing this answer :)

提交回复
热议问题