From 2eaedd5813bd43e041a49f1366079f88d3dfacef Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Fri, 16 Dec 2016 15:14:36 +0100 Subject: [PATCH] Use center and zoom from style for OL3 --- src/ol3.jsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ol3.jsx b/src/ol3.jsx index 903c1c4..253c141 100644 --- a/src/ol3.jsx +++ b/src/ol3.jsx @@ -32,17 +32,19 @@ export class OpenLayers3Map extends Map { 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) const map = new ol.Map({ target: this.container, layers: [this.layer], view: new ol.View({ - center: [949282, 6002552], - zoom: 4 + center: jsonStyle.center, + zoom: jsonStyle.zoom, }) }) + map.addControl(new ol.control.Zoom()); this.setState({ map }); } }