我有两个LatLng坐标点。然后我根据该坐标绘制一条折线。如何使多段线图适合屏幕顶部并缩小以查看全线? LatLngBounds.Builder是否是正确的解决方案?
这些是我现在正在使用的代码
LatLngBounds.Builder builder = new LatLngBounds.Builder();
//latlong and latlong1 are my two points.
String[] latlong = pickUp.split(",");
LatLng location = new LatLng(Double.parseDouble(latlong[0]), Double.parseDouble(latlong[1]));
String[] latlong1 = destination.split(",");
LatLng location1 = new LatLng(Double.parseDouble(latlong1[0]), Double.parseDouble(latlong1[1]));
builder.include(location);
builder.include(location1);
LatLngBounds bounds = builder.build();
int padding = 40;
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);
mMap.animateCamera(cu);