Updated ol-mapbox-style/ol, added throttle to ol map update and fix to clear layers.

This commit is contained in:
orangemug
2019-05-22 07:32:06 +01:00
parent c3c0c35d8a
commit 1cf36ddb08
3 changed files with 127 additions and 135 deletions

View File

@@ -1,4 +1,5 @@
import React from 'react'
import {throttle} from 'lodash';
import PropTypes from 'prop-types'
import { loadJSON } from '../../libs/urlopen'
@@ -22,10 +23,14 @@ export default class OpenLayersMap extends React.Component {
constructor(props) {
super(props);
this.updateStyle = throttle(this._updateStyle.bind(this), 200);
}
updateStyle(newMapStyle) {
_updateStyle(newMapStyle) {
if(!this.map) return;
// See <https://github.com/openlayers/ol-mapbox-style/issues/215#issuecomment-493198815>
this.map.getLayers().clear();
apply(this.map, newMapStyle);
}