0

Доброго времени суток.
Рисую маршрут с помощью Google Maps JavaScript API. Включаю отрисовку маршрута примерно таким кодом:

directionsService.route({
    origin: start,
    destination: finish,
    waypoints: waypoints,
    optimizeWaypoints: true,
    travelMode: google.maps.TravelMode.DRIVING
}, function(response, status) {
    if (status === google.maps.DirectionsStatus.OK) {
        directionsDisplay.setDirections(response);
    } else {
        window.alert('Проблема: ' + status);
    }
});

При подобной отрисовке маршрута карта перематывается и приближается так, чтобы маршрут был целиком на экране. Как предотвратить эту перемотку?
Заранее спасибо.

1 ответ 1

2

DirectionsRendererOptions object specification preserveViewport

Type: boolean By default, the input map is centered and zoomed to the bounding box of this set of directions. If this option is set to true, the viewport is left unchanged, unless the map's center and zoom were never set.

В общем, при создании directionsDisplay в опциях нужно указать

{preserveViewport: true}

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.