我试图在Google地图上绘制路线后适应地图的边界,由于某种原因,下面的内容没有得到应用,似乎它被忽略了,我甚至试图设置手动缩放,它也被忽略了:
var bounds = response.routes[0].bounds;
this.map.fitBounds(bounds);
function calculateAndDisplayRoute(directionsService, directionsDisplay) {
directionsService.route({
origin: pickUp.formattedAddress,
destination: dropOff.formattedAddress,
travelMode: 'DRIVING'
}, function(response, status) {
if (status === 'OK') {
var bounds = response.routes[0].bounds;
this.map.fitBounds(bounds);
} else {
console.log('Directions request failed due to ' + status);
}
});
}