From 43adcfc665699d50e3476a934d6c010877e0be89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laura=20Kl=C3=BCnder?= Date: Wed, 22 Nov 2017 21:43:01 +0100 Subject: [PATCH] choose a safer value for max bounds --- src/c3nav/site/static/site/js/c3nav.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/c3nav/site/static/site/js/c3nav.js b/src/c3nav/site/static/site/js/c3nav.js index cb6232c9..2b37a571 100644 --- a/src/c3nav/site/static/site/js/c3nav.js +++ b/src/c3nav/site/static/site/js/c3nav.js @@ -77,7 +77,6 @@ c3nav = { c3nav._push_state(new_state, replace); c3nav._sidebar_state_updated(new_state); - c3nav.set_max_bounds(); }, update_map_state: function (replace, level, center, zoom) { var new_state = { @@ -214,7 +213,6 @@ c3nav = { c3nav._locationinput_set($('#destination-input'), state.destination); c3nav._sidebar_state_updated(state); if (state.center) { - c3nav.set_max_bounds(state.zoom); c3nav._levelControl.setLevel(state.level); var center = c3nav.map._limitCenter(L.GeoJSON.coordsToLatLng(state.center), state.zoom, c3nav.map.options.maxBounds); if (nofly) { @@ -555,7 +553,6 @@ c3nav = { c3nav.update_map_state(); }, _map_zoomed: function () { - c3nav.set_max_bounds(); c3nav.update_map_state(); }, _add_icon: function (name) { @@ -601,7 +598,6 @@ c3nav = { c3nav._levelControl.setLevel(level); if (bounds) { var target = c3nav.map._getBoundsCenterZoom(bounds, c3nav._add_map_padding({})); - c3nav.set_max_bounds(target.zoom); var center = c3nav.map._limitCenter(target.center, target.zoom, c3nav.map.options.maxBounds); if (nofly) { c3nav.map.flyTo(center, target.zoom, { animate: false }); @@ -627,16 +623,12 @@ c3nav = { _get_padded_max_bounds: function(zoom) { if (zoom === undefined) zoom = c3nav.map.getZoom(); var bounds = c3nav.bounds, - pad = c3nav._add_map_padding({}), factor = Math.pow(2, zoom); return [ - [bounds[0][0]-(pad.paddingTopLeft.x+10)/factor, bounds[0][1]-(pad.paddingBottomRight.y+10)/factor], - [bounds[1][0]+(pad.paddingBottomRight.x+10)/factor, bounds[1][1]+(pad.paddingTopLeft.y+10)/factor] + [bounds[0][0]-510/factor, bounds[0][1]-30/factor], + [bounds[1][0]+60/factor, bounds[1][1]+160/factor] ]; }, - set_max_bounds: function(zoom) { - c3nav.map.setMaxBounds(L.GeoJSON.coordsToLatLngs(c3nav._get_padded_max_bounds(zoom))); - }, _add_location_to_map: function(location, icon) { // add a location to the map as a marker if (location.locations) {