使用 mapbox 使屏幕尺寸适合 android 中的两个标记
Fit the screen size to two markers in android using mapbox
我正在使用 mapbox 来显示地图并获取两个标记之间的路线。现在我试图让屏幕尺寸适合两个标记。那么在 mapbox 中使用 android.
的方法是什么?
为了完成此操作,您需要创建一个 LatLngBounds
,然后缩放到该位置。
所以使用最新的 SDK 版本 4.0.0,您可以使用以下代码实现此目的:
LatLngBounds latLngBounds = new LatLngBounds.Builder()
.include(first marker position)
.include(second marker position)
.build();
CameraUpdateFactory.newLatLngBounds(latLngBounds, 10);
您可以根据需要将任意数量的 LatLng
添加到边界框内。希望这对您有所帮助!
我正在使用 mapbox 来显示地图并获取两个标记之间的路线。现在我试图让屏幕尺寸适合两个标记。那么在 mapbox 中使用 android.
的方法是什么?为了完成此操作,您需要创建一个 LatLngBounds
,然后缩放到该位置。
所以使用最新的 SDK 版本 4.0.0,您可以使用以下代码实现此目的:
LatLngBounds latLngBounds = new LatLngBounds.Builder()
.include(first marker position)
.include(second marker position)
.build();
CameraUpdateFactory.newLatLngBounds(latLngBounds, 10);
您可以根据需要将任意数量的 LatLng
添加到边界框内。希望这对您有所帮助!