mirror of
https://github.com/maputnik/editor.git
synced 2025-12-25 23:50:02 +00:00
Updated ol-mapbox-style/ol, added throttle to ol map update and fix to clear layers.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user