aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuc Donnet2018-01-05 22:29:27 +0100
committerGitHub2018-01-05 22:29:27 +0100
commit90762efa54ffca067e04dfe9fff7fdc95dc50a70 (patch)
tree6f4796159c7da8b748098e8bbc26f0c0ba3b4d1d
parent4ca46f30dfaf0680dcfd07f935156fd498360281 (diff)
parenteda4d2439b07b06599e5e1560fa95e8f90bf6066 (diff)
downloadchouette-core-90762efa54ffca067e04dfe9fff7fdc95dc50a70.tar.bz2
Merge pull request #200 from af83/5465-dezoom-routes-show
5465 Fit map zoom on Route#show to display all stop areas
-rw-r--r--app/javascript/packs/routes/show.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/app/javascript/packs/routes/show.js b/app/javascript/packs/routes/show.js
index 7f14a6f11..4d91ace13 100644
--- a/app/javascript/packs/routes/show.js
+++ b/app/javascript/packs/routes/show.js
@@ -4,6 +4,7 @@ route = JSON.parse(decodeURIComponent(route))
const geoColPts = []
const geoColLns = []
+const area = []
const geoColEdges = [
new ol.Feature({
geometry: new ol.geom.Point(ol.proj.fromLonLat([parseFloat(route[0].longitude), parseFloat(route[0].latitude)]))
@@ -23,8 +24,8 @@ route.forEach(function (stop, i) {
}
geoColPts.push(new ol.Feature({
geometry: new ol.geom.Point(ol.proj.fromLonLat([parseFloat(stop.longitude), parseFloat(stop.latitude)]))
- })
- )
+ }))
+ area.push([parseFloat(stop.longitude), parseFloat(stop.latitude)])
})
var edgeStyles = new ol.style.Style({
image: new ol.style.Circle(({
@@ -100,3 +101,7 @@ var map = new ol.Map({
zoom: 13
})
});
+const boundaries = ol.extent.applyTransform(
+ ol.extent.boundingExtent(area), ol.proj.getTransform('EPSG:4326', 'EPSG:3857')
+)
+map.getView().fit(boundaries, map.getSize());