frontend: Make home zone configurable
This commit is contained in:
parent
35fc7193b7
commit
aaea78daf7
|
@ -8,6 +8,7 @@ import OlGroupLayer from 'ol/layer/Group'
|
||||||
import OSM from 'ol/source/OSM'
|
import OSM from 'ol/source/OSM'
|
||||||
import proj4 from 'proj4'
|
import proj4 from 'proj4'
|
||||||
import {register} from 'ol/proj/proj4'
|
import {register} from 'ol/proj/proj4'
|
||||||
|
import {fromLonLat} from 'ol/proj'
|
||||||
|
|
||||||
// Import styles for open layers + addons
|
// Import styles for open layers + addons
|
||||||
import 'ol/ol.css'
|
import 'ol/ol.css'
|
||||||
|
@ -116,14 +117,22 @@ function FitView({extent}) {
|
||||||
return null
|
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}) {
|
function View({...options}) {
|
||||||
const map = React.useContext(MapContext)
|
const map = React.useContext(MapContext)
|
||||||
|
|
||||||
const view = React.useMemo(
|
const view = React.useMemo(
|
||||||
() =>
|
() =>
|
||||||
new OlView({
|
new OlView({
|
||||||
minZoom: config.mapTileset?.minZoom ?? 0,
|
minZoom,
|
||||||
maxZoom: config.mapTileset?.maxZoom ?? 18,
|
maxZoom,
|
||||||
|
zoom: Math.max(Math.min(mapHomeZoom, maxZoom), minZoom),
|
||||||
|
center: fromLonLat([mapHomeLongitude, mapHomeLatitude]),
|
||||||
...options,
|
...options,
|
||||||
}),
|
}),
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
|
|
@ -12,5 +12,10 @@
|
||||||
"url": "https://tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png",
|
"url": "https://tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png",
|
||||||
"minZoom": 0,
|
"minZoom": 0,
|
||||||
"maxZoom": 18
|
"maxZoom": 18
|
||||||
|
},
|
||||||
|
"mapHome": {
|
||||||
|
"zoom": 15,
|
||||||
|
"longitude": 9.1797,
|
||||||
|
"latitude": 48.7784
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,5 +12,10 @@
|
||||||
"url": "https://tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png",
|
"url": "https://tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png",
|
||||||
"minZoom": 0,
|
"minZoom": 0,
|
||||||
"maxZoom": 18
|
"maxZoom": 18
|
||||||
|
},
|
||||||
|
"mapHome": {
|
||||||
|
"zoom": 15,
|
||||||
|
"longitude": 9.1797,
|
||||||
|
"latitude": 48.7784
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ function WelcomeMap() {
|
||||||
<Map className={styles.welcomeMap}>
|
<Map className={styles.welcomeMap}>
|
||||||
<RoadsLayer />
|
<RoadsLayer />
|
||||||
<Map.BaseLayer />
|
<Map.BaseLayer />
|
||||||
<Map.View zoom={13} center={fromLonLat([9.1798, 48.7759])} />
|
<Map.View />
|
||||||
</Map>
|
</Map>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,7 +221,7 @@ export default function TrackMap({trackData, show, ...props}: {trackData: TrackD
|
||||||
<PointLayer features={trackPointsUntaggedD2} title="Right Untagged" visible={show.rightUnconfirmed} />
|
<PointLayer features={trackPointsUntaggedD2} title="Right Untagged" visible={show.rightUnconfirmed} />
|
||||||
</Map.GroupLayer>
|
</Map.GroupLayer>
|
||||||
|
|
||||||
<Map.View zoom={15} center={fromLonLat([9.1797, 48.7784])} />
|
<Map.View />
|
||||||
<Map.FitView extent={viewExtent} />
|
<Map.FitView extent={viewExtent} />
|
||||||
</Map>
|
</Map>
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue