diff --git a/frontend/src/components/Map/index.js b/frontend/src/components/Map/index.js
index fc786ed..9b98ddb 100644
--- a/frontend/src/components/Map/index.js
+++ b/frontend/src/components/Map/index.js
@@ -8,6 +8,7 @@ import OlGroupLayer from 'ol/layer/Group'
import OSM from 'ol/source/OSM'
import proj4 from 'proj4'
import {register} from 'ol/proj/proj4'
+import {fromLonLat} from 'ol/proj'
// Import styles for open layers + addons
import 'ol/ol.css'
@@ -116,14 +117,22 @@ function FitView({extent}) {
return null
}
+const minZoom = config.mapTileset?.minZoom ?? 0
+const maxZoom = config.mapTileset?.maxZoom ?? 18
+const mapHomeZoom = config.mapHome?.zoom ?? 15
+const mapHomeLongitude = config.mapHome?.longitude ?? 9.1797
+const mapHomeLatitude = config.mapHome?.latitude ?? 48.7784
+
function View({...options}) {
const map = React.useContext(MapContext)
const view = React.useMemo(
() =>
new OlView({
- minZoom: config.mapTileset?.minZoom ?? 0,
- maxZoom: config.mapTileset?.maxZoom ?? 18,
+ minZoom,
+ maxZoom,
+ zoom: Math.max(Math.min(mapHomeZoom, maxZoom), minZoom),
+ center: fromLonLat([mapHomeLongitude, mapHomeLatitude]),
...options,
}),
// eslint-disable-next-line react-hooks/exhaustive-deps
diff --git a/frontend/src/config.dev.json b/frontend/src/config.dev.json
index 6ba6fe9..c276d22 100644
--- a/frontend/src/config.dev.json
+++ b/frontend/src/config.dev.json
@@ -12,5 +12,10 @@
"url": "https://tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png",
"minZoom": 0,
"maxZoom": 18
+ },
+ "mapHome": {
+ "zoom": 15,
+ "longitude": 9.1797,
+ "latitude": 48.7784
}
}
diff --git a/frontend/src/config.json.example b/frontend/src/config.json.example
index 43f889c..9e1716e 100644
--- a/frontend/src/config.json.example
+++ b/frontend/src/config.json.example
@@ -12,5 +12,10 @@
"url": "https://tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png",
"minZoom": 0,
"maxZoom": 18
+ },
+ "mapHome": {
+ "zoom": 15,
+ "longitude": 9.1797,
+ "latitude": 48.7784
}
}
diff --git a/frontend/src/pages/HomePage.tsx b/frontend/src/pages/HomePage.tsx
index 0cdbcba..13945ad 100644
--- a/frontend/src/pages/HomePage.tsx
+++ b/frontend/src/pages/HomePage.tsx
@@ -17,7 +17,7 @@ function WelcomeMap() {
)
}
diff --git a/frontend/src/pages/TrackPage/TrackMap.tsx b/frontend/src/pages/TrackPage/TrackMap.tsx
index 0e68d6e..683407b 100644
--- a/frontend/src/pages/TrackPage/TrackMap.tsx
+++ b/frontend/src/pages/TrackPage/TrackMap.tsx
@@ -221,7 +221,7 @@ export default function TrackMap({trackData, show, ...props}: {trackData: TrackD
-
+
)