add padding and xy→yx conversion in initial fitBounds

This commit is contained in:
Laura Klünder 2017-10-30 21:15:08 +01:00
parent 24f460d269
commit 46dab72c01

View file

@ -334,7 +334,7 @@ c3nav = {
zoomSnap: 0, zoomSnap: 0,
zoomControl: false zoomControl: false
}); });
c3nav.map.fitBounds(c3nav.bounds, {padding: [30, 50]}); c3nav.map.fitBounds(L.GeoJSON.coordsToLatLngs(c3nav.bounds), c3nav._add_map_padding({}));
// set up icons // set up icons
L.Icon.Default.imagePath = '/static/leaflet/images/'; L.Icon.Default.imagePath = '/static/leaflet/images/';
@ -407,15 +407,15 @@ c3nav = {
top = (left === 0) ? $('#search').height()+10 : 10; top = (left === 0) ? $('#search').height()+10 : 10;
c3nav.map.flyToBounds(bounds, c3nav._add_map_padding({ c3nav.map.flyToBounds(bounds, c3nav._add_map_padding({
duration: 1 duration: 1
}, 'paddingTopLeft', 'paddingBottomRight')); }));
} }
}, },
_add_map_padding: function(options, topleft, bottomright) { _add_map_padding: function(options, topleft, bottomright) {
// add padding information for the current ui layout to fitBoudns options // add padding information for the current ui layout to fitBoudns options
var left = 0, var left = 0,
top = (left === 0) ? $('#search').height()+10 : 10; top = (left === 0) ? $('#search').height()+10 : 10;
options[topleft] = L.point(left+13, top+41); options[topleft || 'paddingTopLeft'] = L.point(left+13, top+41);
options[bottomright] = L.point(50, 20); options[bottomright || 'paddingBottomRight'] = L.point(50, 0);
return options; return options;
}, },
_add_location_to_map: function(location, icon) { _add_location_to_map: function(location, icon) {