diff options
| author | Luc Donnet | 2018-01-11 15:45:37 +0100 |
|---|---|---|
| committer | GitHub | 2018-01-11 15:45:37 +0100 |
| commit | 6be4f648ed5f200af7dbe8843d24361c8c9f2b63 (patch) | |
| tree | 06e0a63f03ea0ee89b002b6052564a2764ba4f4b | |
| parent | b56d9e01cf1e8a0cf50c597c863c2b775b7a322d (diff) | |
| parent | 56df55a4d3ffc65b483fe05b800299f04b61077f (diff) | |
| download | chouette-core-6be4f648ed5f200af7dbe8843d24361c8c9f2b63.tar.bz2 | |
Merge pull request #221 from af83/5465-dezoom-map-if-too-close-to-borders
5465 Dezoom map if stop areas are too cleose to borders
| -rw-r--r-- | app/javascript/packs/routes/show.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/app/javascript/packs/routes/show.js b/app/javascript/packs/routes/show.js index 4d91ace13..71777c379 100644 --- a/app/javascript/packs/routes/show.js +++ b/app/javascript/packs/routes/show.js @@ -105,3 +105,17 @@ const boundaries = ol.extent.applyTransform( ol.extent.boundingExtent(area), ol.proj.getTransform('EPSG:4326', 'EPSG:3857') ) map.getView().fit(boundaries, map.getSize()); +let tooCloseToBounds = false +const mapBoundaries = map.getView().calculateExtent(map.getSize()) +const mapWidth = mapBoundaries[2] - mapBoundaries[0] +const mapHeight = mapBoundaries[3] - mapBoundaries[1] +const marginSize = 0.1 +const heightMargin = marginSize * mapHeight +const widthMargin = marginSize * mapWidth +tooCloseToBounds = tooCloseToBounds || (boundaries[0] - mapBoundaries[0]) < widthMargin +tooCloseToBounds = tooCloseToBounds || (mapBoundaries[2] - boundaries[2]) < widthMargin +tooCloseToBounds = tooCloseToBounds || (boundaries[1] - mapBoundaries[1]) < heightMargin +tooCloseToBounds = tooCloseToBounds || (mapBoundaries[3] - boundaries[3]) < heightMargin +if(tooCloseToBounds){ + map.getView().setZoom(map.getView().getZoom() - 1) +} |
