diff options
| author | Zog | 2018-01-10 08:42:25 +0100 |
|---|---|---|
| committer | Zog | 2018-01-10 08:42:25 +0100 |
| commit | 56df55a4d3ffc65b483fe05b800299f04b61077f (patch) | |
| tree | 101f265f8d650ea94615c5f99c61ff6568e04ad3 | |
| parent | 2fa6e52c311a0ca63d6bb6339bb056ee0dad5b8c (diff) | |
| download | chouette-core-56df55a4d3ffc65b483fe05b800299f04b61077f.tar.bz2 | |
Refs #5465 @0.25h; 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) +} |
