if (dragging && awaitingRoute) return;
endpoint.setLatLng(e.target.getLatLng());
if (map.hasLayer(polyline)) {
- getRoute();
+ getRoute(false);
}
});
if (awaitingGeocode) {
awaitingGeocode = false;
- getRoute();
+ getRoute(true);
}
});
};
});
}
- function getRoute() {
+ function getRoute(fitRoute) {
// Cancel any route that is already in progress
if (awaitingRoute) awaitingRoute.abort();
.setLatLngs(route.line)
.addTo(map);
- if (!dragging) {
+ if (fitRoute) {
map.fitBounds(polyline.getBounds().pad(0.05));
}
chosenEngine = engines[e.target.selectedIndex];
$.cookie('_osm_directions_engine', chosenEngine.id, { expires: expiry, path: '/' });
if (map.hasLayer(polyline)) {
- getRoute();
+ getRoute(true);
}
});
$(".directions_form").on("submit", function(e) {
e.preventDefault();
- getRoute();
+ getRoute(true);
});
$(".routing_marker").on('dragstart', function (e) {
pt.y += 20;
var ll = map.containerPointToLatLng(pt);
endpoints[type === 'from' ? 0 : 1].setLatLng(ll);
- getRoute();
+ getRoute(true);
});
var params = querystring.parse(location.search.substring(1)),
map.setSidebarOverlaid(!from || !to);
- getRoute();
+ getRoute(true);
};
page.load = function() {