diff --git a/examples/deckgl-overlay/src/app.js b/examples/deckgl-overlay/src/app.js index 4f55eb34..bd3c2117 100644 --- a/examples/deckgl-overlay/src/app.js +++ b/examples/deckgl-overlay/src/app.js @@ -3,6 +3,8 @@ import {render} from 'react-dom'; import DeckGL, {ArcLayer} from 'deck.gl'; import MapGL from 'react-map-gl'; +const TOKEN = ''; // Set your mapbox token here + export default class App extends Component { constructor(props) { super(props); @@ -31,7 +33,7 @@ export default class App extends Component { height="100%" maxPitch={85} onViewportChange={this._onViewportChange} - mapboxApiAccessToken="" + mapboxApiAccessToken={TOKEN} > [ - location.longitude + Math.random() * 0.01, - location.latitude + Math.random() * 0.01 - ]) -); - -function buildStyle({fill = 'red', stroke = 'blue'}) { - return Immutable.fromJS({ - version: 8, - name: 'Example raster tile source', - sources: { - 'my-geojson-polygon-source': { - type: 'geojson', - data: SF_FEATURE - } - }, - layers: [ - { - id: 'geojson-polygon-fill', - source: 'my-geojson-polygon-source', - type: 'fill', - paint: {'fill-color': fill, 'fill-opacity': 0.4}, - interactive: true - }, - { - id: 'geojson-polygon-stroke', - source: 'my-geojson-polygon-source', - type: 'line', - paint: {'line-color': stroke, 'line-width': 4}, - interactive: false - } - ] - }); -} - -const propTypes = { - width: PropTypes.number.isRequired, - height: PropTypes.number.isRequired -}; - -export default class Example extends Component { - constructor(props) { - super(props); - this.state = { - viewport: { - latitude: location.latitude, - longitude: location.longitude, - zoom: 11, - bearing: 180, - pitch: 60 - }, - mapStyle: buildStyle({stroke: '#FF00FF', fill: 'green'}) - }; - autobind(this); - } - - UNSAFE_componentWillMount() { - const colors = ['red', 'green', 'blue']; - let i = 0; - window.setInterval( - function interval() { - this.setState({ - mapStyle: buildStyle({ - stroke: colors[i % colors.length], - fill: colors[(i + 1) % colors.length] - }) - }); - i = i + 1; - }.bind(this), - 2000 - ); - } - - _onViewportChange(opt) { - this.setState({viewport: opt}); - } - - _onClickFeatures(event) { - window.console.log(event.features); - } - - render() { - const viewport = { - // mapStyle: this.state.mapStyle, - ...this.state.viewport, - ...this.props - }; - return ( - - - - [0, 0, 255], - getTargetColor: x => [0, 255, 0] - }) - ]} - /> - - ); - } -} - -Example.propTypes = propTypes; diff --git a/examples/main/example-container.js b/examples/main/example-container.js index 8943aa7d..57c6d08b 100644 --- a/examples/main/example-container.js +++ b/examples/main/example-container.js @@ -32,7 +32,7 @@ export default class App extends Component { }; } - UNSAFE_componentWillMount() { + componentDidMount() { window.onresize = () => this.setState({ viewport: { diff --git a/examples/main/views/style-diffing.js b/examples/main/views/style-diffing.js index 87ea0ce3..0c4fa8c4 100644 --- a/examples/main/views/style-diffing.js +++ b/examples/main/views/style-diffing.js @@ -80,7 +80,7 @@ export default class StyleDiffingExample extends Component { this._onClick = this._onClick.bind(this); } - UNSAFE_componentWillMount() { + componentDidMount() { const colors = ['red', 'green', 'blue']; let i = 0; this._intervalId = window.setInterval( diff --git a/src/components/interactive-map.js b/src/components/interactive-map.js index 71756043..60dbf701 100644 --- a/src/components/interactive-map.js +++ b/src/components/interactive-map.js @@ -245,14 +245,6 @@ export default class InteractiveMap extends PureComponent, radius: number}) { @@ -315,6 +308,7 @@ export default class InteractiveMap extends PureComponent { const {isDragging = false} = interactionState; if (isDragging !== this.state.isDragging) { + this._updateInteractiveContext({isDragging}); this.setState({isDragging}); } @@ -495,6 +489,8 @@ export default class InteractiveMap extends PureComponent