mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-28 17:31:14 +01:00
Use center and zoom from style for OL3
This commit is contained in:
parent
43573fcd8c
commit
2eaedd5813
1 changed files with 5 additions and 3 deletions
|
@ -32,17 +32,19 @@ export class OpenLayers3Map extends Map {
|
||||||
|
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const styleFunc = olms.getStyleFunction(style.toJSON(this.props.mapStyle), 'mapbox', this.resolutions)
|
const jsonStyle = style.toJSON(this.props.mapStyle)
|
||||||
|
const styleFunc = olms.getStyleFunction(jsonStyle, 'mapbox', this.resolutions)
|
||||||
this.layer.setStyle(styleFunc)
|
this.layer.setStyle(styleFunc)
|
||||||
|
|
||||||
const map = new ol.Map({
|
const map = new ol.Map({
|
||||||
target: this.container,
|
target: this.container,
|
||||||
layers: [this.layer],
|
layers: [this.layer],
|
||||||
view: new ol.View({
|
view: new ol.View({
|
||||||
center: [949282, 6002552],
|
center: jsonStyle.center,
|
||||||
zoom: 4
|
zoom: jsonStyle.zoom,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
map.addControl(new ol.control.Zoom());
|
||||||
this.setState({ map });
|
this.setState({ map });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue