Skip to content

Commit

Permalink
Improved focusing map view to include markers
Browse files Browse the repository at this point in the history
  • Loading branch information
nenad-vujicic committed Jul 8, 2024
1 parent 319faff commit afc0f21
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion app/assets/javascripts/index/directions.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,14 @@ OSM.Directions = function (map) {
$("#sidebar_content").html("<div class=\"alert alert-danger\">" + I18n.t("javascripts.directions.errors.no_route") + "</div>");
}

if (fitRoute) {
var partiallyCombinedBounds = L.latLngBounds();
partiallyCombinedBounds.extend(L.latLngBounds(o, o));
partiallyCombinedBounds.extend(L.latLngBounds(d, d));

map.fitBounds(partiallyCombinedBounds.pad(0.05));
}

return;
}

Expand All @@ -271,7 +279,12 @@ OSM.Directions = function (map) {
.addTo(map);

if (fitRoute) {
map.fitBounds(polyline.getBounds().pad(0.05));
var fullyCombinedBounds = L.latLngBounds();
fullyCombinedBounds.extend(polyline.getBounds());
fullyCombinedBounds.extend(L.latLngBounds(o, o));
fullyCombinedBounds.extend(L.latLngBounds(d, d));

map.fitBounds(fullyCombinedBounds.pad(0.05));
}

var distanceText = $("<p>").append(
Expand Down

0 comments on commit afc0f21

Please sign in to comment.