Я использую ionic-native-google-map для отображения карты в моем приложении Ionic 3. Я отрисовал ломаную линию от некоторых точек LatLng. Теперь я хочу разместить ломаную линию на карте так, чтобы сразу увидеть всю ломаную линию на карте. Я использую код ниже:
ionViewDidLoad() {
this.platform.ready().then(() => {
let element = this.mapElement.nativeElement;
let latLngPointBounds = new LatLngBounds(this.routePoints);
let mapOptions: GoogleMapOptions = {
camera: {
target: latLngPointBounds.getCenter(),
zoom: 20
},
controls: {
compass: true,
myLocationButton: true,
myLocation: true,
zoom: true,
mapToolbar: true
}
};
this.map = GoogleMaps.create(element, mapOptions);
this.map.one(GoogleMapsEvent.MAP_READY).then(() => {
this.map.addPolyline({
points: this.routePoints,
'color': '#AA00FF',
'width': 4,
'geodesic': true
}).then((resp) => {
let restaurantMarkerOptions: MarkerOptions = {
title: "Sample Title",
position: this.routePoints[this.routePoints.length - 1],
animation: GoogleMapsAnimation.BOUNCE
};
this.map.addMarker(restaurantMarkerOptions).then((marker: Marker) => {
marker.showInfoWindow();
});
});
});
});
}
Вы можете видеть, что я установил зум: 20 , поэтому для некоторой полилинии он прекрасно подходит.

Но некоторые полилинии не подходят для этого уровня масштабирования.

Итак, как я могу динамически установить масштаб, чтобы я всегда мог уместить всю полилинию на карте без увеличения или уменьшения масштаба?
Есть ли какая-либо настройка LatLngBounds для этого?