Commit 9e3596e9 authored by Oleksii Savran's avatar Oleksii Savran Committed by Matija Obreza
Browse files

Max map bounds

parent 2d2fa8ae
......@@ -311,12 +311,25 @@ class BrowsePage extends React.Component<IMapPageProps, any> {
const { searchBox, geoData, otherCount, sidebarOpened, trackClickPos, dialogOpened, climateData, layersControlsIsOpen} = this.state;
const { mapInfo, mapLayers, currentTab, classes, filterCode, loading, suggestions, t, loadAccessionsMapInfo, initialPosition, initialZoom } = this.props;
const position = initialPosition[0] && initialPosition[1] ? initialPosition : [30, 0];
const position = initialPosition[0] && initialPosition[1] ? initialPosition : [5, 5];
const initialBounds = [
[-40, 60],
[50, -50],
];
if (! mapInfo) {
return <Loading />;
}
if (Math.abs(mapInfo.bounds[0][0] - mapInfo.bounds[1][0]) < Math.abs(initialBounds[0][0] - initialBounds[1][0])) {
initialBounds[0][0] = mapInfo.bounds[0][0];
initialBounds[1][0] = mapInfo.bounds[1][0];
}
if (Math.abs(mapInfo.bounds[0][1] - mapInfo.bounds[1][1]) < Math.abs(initialBounds[0][1] - initialBounds[1][1])) {
initialBounds[0][1] = mapInfo.bounds[0][1];
initialBounds[1][1] = mapInfo.bounds[1][1];
}
const suggestionTerms = new Map();
if (suggestions) {
Object.keys(suggestions).forEach((key) => {
......@@ -378,7 +391,8 @@ class BrowsePage extends React.Component<IMapPageProps, any> {
onClick={ this.onMapClick }
center={ position }
zoom={ initialZoom || 3 } minZoom={ 2 } maxZoom={ 14 }
bounds={ !initialZoom && initialPosition[0] && !initialPosition[1] ? mapInfo.bounds : undefined }
zoomDelta={ 0.5 }
bounds={ !initialZoom && initialPosition[0] && !initialPosition[1] ? mapInfo.bounds : initialBounds }
ref={ (ref) => this.mapRef = ref }
>
<Control position="topleft">
......@@ -415,7 +429,7 @@ class BrowsePage extends React.Component<IMapPageProps, any> {
>
<Button
variant="contained"
className={ `${classes.mapButton} ${classes.layersButton}` } /*onClick={ this.openLayersControls }*/
className={ `${classes.mapButton} ${classes.layersButton}` }
onClick={ this.openLayersControls }
>
<LayersIcon/>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment