├── .babelrc
├── .eslintignore
├── .eslintrc.json
├── .gitignore
├── LICENSE
├── README.md
├── example
├── src
│ ├── example.jsx
│ └── index.jsx
├── web
│ ├── example.html
│ └── index.html
└── webpack.config.js
├── index.js
├── package.json
├── src
├── evented.jsx
├── facades
│ ├── map.jsx
│ └── transform.jsx
├── index.js
├── map-events.jsx
├── map.jsx
└── utils
│ ├── index.jsx
│ ├── map.jsx
│ ├── styles.jsx
│ └── transform.jsx
└── yarn.lock
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [ "react", "es2015", "stage-1"],
3 | "plugins": [ ],
4 | "env": {
5 | "test": {
6 | "plugins": ["istanbul"]
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | example/webpack.config.js
2 |
--------------------------------------------------------------------------------
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "airbnb",
3 | "parserOptions": {
4 | "ecmaVersion": 6,
5 | "sourceType": "module",
6 | "ecmaFeatures": {
7 | "modules": true,
8 | "jsx": true,
9 | "experimentalObjectRestSpread": true,
10 | "destructuring": true
11 | }
12 | },
13 | "rules": {
14 | "new-cap": [2, { "capIsNewExceptions": ["List", "Map", "Seq", "Immutable", "Dimensions", "ViewportMercator", "Promise"] }],
15 | "one-var": [0],
16 | "no-underscore-dangle": [0],
17 | "no-console": [0],
18 | "max-len": [0]
19 | },
20 | "env": {
21 | "browser": true,
22 | "es6": true,
23 | "mocha": true
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 |
6 | # Runtime data
7 | pids
8 | *.pid
9 | *.seed
10 |
11 | # Directory for instrumented libs generated by jscoverage/JSCover
12 | lib-cov
13 |
14 | # Coverage directory used by tools like istanbul
15 | coverage
16 |
17 | # nyc test coverage
18 | .nyc_output
19 |
20 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
21 | .grunt
22 |
23 | # node-waf configuration
24 | .lock-wscript
25 |
26 | # Compiled binary addons (http://nodejs.org/api/addons.html)
27 | build/Release
28 |
29 | # Dependency directories
30 | node_modules
31 | jspm_packages
32 |
33 | # Optional npm cache directory
34 | .npm
35 |
36 | # Optional REPL history
37 | .node_repl_history
38 |
39 | # Example dist
40 | example/web/dist
41 | example/web/bundle.js
42 |
43 | # Output
44 | dist/
45 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 Cameron Manderson
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 | ---
24 |
25 | This contains code from react-map-gl
26 |
27 | Copyright (c) 2015 Uber Technologies, Inc.
28 |
29 | Permission is hereby granted, free of charge, to any person obtaining a copy
30 | of this software and associated documentation files (the "Software"), to deal
31 | in the Software without restriction, including without limitation the rights
32 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
33 | copies of the Software, and to permit persons to whom the Software is
34 | furnished to do so, subject to the following conditions:
35 |
36 | The above copyright notice and this permission notice shall be included in
37 | all copies or substantial portions of the Software.
38 |
39 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
40 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
41 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
42 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
43 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
44 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
45 | THE SOFTWARE.
46 |
47 | ---
48 |
49 | This contains code from MapboxGL-js
50 |
51 | Copyright (c) 2014, Mapbox
52 |
53 | All rights reserved.
54 | Redistribution and use in source and binary forms, with or without modification,
55 | are permitted provided that the following conditions are met:
56 |
57 | * Redistributions of source code must retain the above copyright notice,
58 | this list of conditions and the following disclaimer.
59 | * Redistributions in binary form must reproduce the above copyright notice,
60 | this list of conditions and the following disclaimer in the documentation
61 | and/or other materials provided with the distribution.
62 | * Neither the name of Mapbox GL JS nor the names of its contributors
63 | may be used to endorse or promote products derived from this software
64 | without specific prior written permission.
65 |
66 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
67 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
68 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
69 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
70 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
71 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
72 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
73 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
74 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
75 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
76 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
77 |
78 | -------------------------------------------------------------------------------
79 |
80 | Contains glmatrix.js
81 |
82 | Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved.
83 |
84 | Redistribution and use in source and binary forms, with or without modification,
85 | are permitted provided that the following conditions are met:
86 |
87 | * Redistributions of source code must retain the above copyright notice, this
88 | list of conditions and the following disclaimer.
89 | * Redistributions in binary form must reproduce the above copyright notice,
90 | this list of conditions and the following disclaimer in the documentation
91 | and/or other materials provided with the distribution.
92 |
93 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
94 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
95 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
96 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
97 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
98 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
99 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
100 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
101 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
102 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
103 |
104 | -------------------------------------------------------------------------------
105 |
106 | Contains Hershey Simplex Font: http://paulbourke.net/dataformats/hershey/
107 |
108 | -------------------------------------------------------------------------------
109 |
110 | Contains code from glfx.js
111 |
112 | Copyright (C) 2011 by Evan Wallace
113 |
114 | Permission is hereby granted, free of charge, to any person obtaining a copy
115 | of this software and associated documentation files (the "Software"), to deal
116 | in the Software without restriction, including without limitation the rights
117 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
118 | copies of the Software, and to permit persons to whom the Software is
119 | furnished to do so, subject to the following conditions:
120 |
121 | The above copyright notice and this permission notice shall be included in
122 | all copies or substantial portions of the Software.
123 |
124 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
125 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
126 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
127 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
128 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
129 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
130 | THE SOFTWARE.
131 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # React WebGL Maps with Mapbox GL JS
2 |
3 | *react-map-gl-alt* provides a [React](http://facebook.github.io/react/) friendly
4 | API wrapper around [Mapbox GL JS](https://www.mapbox.com/mapbox-gl-js/). A webGl
5 | based vector tile mapping library.
6 |
7 | This library is "bare-bones" without the kitchen-sink, for more direct API
8 | interactions with the mapbox API.
9 |
10 | [](https://nodei.co/npm/react-map-gl-alt/)
11 | 
12 |
13 | ## Overview
14 |
15 | This project looks at improved programmatic bindings to the API, motion control,
16 | event handling and style management (such as Redux controlled state opposed to
17 | React or style URLs).
18 |
19 | At a basic level, this library provides your React project with beautiful WebGL
20 | maps that can be used for data visualiations and improved interactivity.
21 |
22 | If you plan on creating simple maps and are new to mapbox gl js, you may find
23 | simpler integrations using [react-mapbox-gl](https://github.com/alex3165/react-mapbox-gl).
24 | If you require finer control of your style, API and want to leverage more of the
25 | API this project we think will help you.
26 |
27 | ## Overview
28 |
29 | ### Installation
30 |
31 | ```
32 | npm install react-map-gl-alt --save
33 | ```
34 |
35 | This package works with compatible mapbox-gl-js build approaches, including
36 | webpack, browserify, etc.
37 |
38 | #### Using Webpack
39 |
40 | You will need to set your resolve "alias" section to include the mapbox gl js
41 | dist file directly. Mapbox GL JS has recommended this approach since version
42 | 0.25.0.
43 |
44 | See [webpack configuration example](https://github.com/AlpacaTravel/react-map-gl-alt/blob/master/example/webpack.config.js)
45 |
46 | ### Simple Usage
47 |
48 | ```jsx
49 | import MapGL from 'react-map-gl-alt';
50 |
51 | // Simple react component returning your webGL map
52 | export const MapExample = () => (
53 |
57 | );
58 | ```
59 |
60 | ## Running the examples
61 |
62 | Clone the example to your local fs. The example shows a simple full screen
63 | interaction controlled by this component (built using webpack etc).
64 |
65 | ```
66 | npm install
67 | npm start
68 | ```
69 |
70 | ### Usage (showing map accessor interaction with map events)
71 |
72 | ```jsx
73 | const hover = (e) => {
74 | // Access features under cursor through safe non-mutable map facade
75 | const features = e.target.queryRenderedFeatures(e.point);
76 | }
77 | const move = (e) => {
78 | // Differentiate user interaction versus flyTo
79 | if (e.originalEvent) {
80 | console.log('A human moved the map');
81 | }
82 | // Access map props (no mutation possible)
83 | console.log(e.target.getCenter(), e.target.getZoom());
84 | }
85 |
86 | // Can update center/zoom etc to move
87 | return (
88 | ({ command: 'flyTo', args: [{
96 | ...target,
97 | // Use animation options, duration etc.
98 | speed: 1.5,
99 | curve: 1.8,
100 | }])}
101 | scrollZoomDisabled={true}
102 | >
103 | { this.setState({ loaded: true }); }}
105 | onError={console.error}
106 | onMouseMove={hover}
107 | onMove={move}
108 | onClick={...}
109 | />
110 |
111 | );
112 | ```
113 |
114 | ## Orienting the viewport
115 |
116 | You can provide a number of props to help control the location of the map. This
117 | includes providing center, longitude latitude or a bounds.
118 |
119 | * Supply a center or longitude/latitude props (LngLat like center is prefered)
120 | * Supply bounds (e.g. LngLatBounds like)
121 | * Supply zoom/bearing/pitch
122 |
123 |
124 | ```jsx
125 | // Using a bounds
126 | return (
127 | ({
130 | command: 'fitBounds',
131 | args: [
132 | target.bounds,
133 | { animate: false, padding: 50 }
134 | ],
135 | })}
136 | />
137 | );
138 | ```
139 |
140 | Note: Mapbox API does not support instantiating a map with just a bounds,
141 | you need to mount the component with a center and then apply your bounds.
142 |
143 | ## Map Options
144 |
145 | You can adjust the map following map options through the `````` exposed
146 | props;
147 |
148 | * scrollZoomDisabled (default false)
149 | * dragRotateDisabled (default false)
150 | * dragPanDisabled (default false)
151 | * keyboardDisabled (default false)
152 | * doubleClickZoomDisabled (default false)
153 | * touchZoomRotateDisabled (default false)
154 | * trackResizeDisabled (default false)
155 | * interactiveDisabled (default false)
156 | * pitchWithRotateDisabled (deafult false)
157 | * attributionControlDisabled (default false)
158 | * failIfMajorPerformanceCaveatDisabled (default false)
159 | * preserveDrawingBuffer (default true)
160 | * bearingSnap (default 7)
161 | * mapClasses (default [])
162 |
163 | There are also some enhanced behaviours to assist.
164 |
165 | * worldCopyJumpDisabled (default true)
166 | * trackResizeContainerDisabled (default true)
167 | * crossSourceCollisionsDisabled (default false)
168 |
169 |
170 | ## The Map Facade
171 |
172 | To reduce the state managed outside of this component, the component offers a
173 | facade to the map object. The facade provides all accessor based methods for
174 | those familiar with the mapbox API spec (e.g. getCenter, getCanvas etc)
175 |
176 | ```jsx
177 | const click = (e) => {
178 | // Access the read only properties of the map
179 | const map = e.target;
180 | }
181 |
182 | ...
183 | return (
184 |
185 |
186 |
187 | );
188 | ```
189 |
190 | This is included along with events from the component/api, replacing the
191 | exposed 'target' event.
192 |
193 | Note: This Map Facade is available to children context.
194 |
195 | ### Transform
196 |
197 | The map facade also offers access to the map transform. This is done through
198 | a Transform Facade.
199 |
200 | ```jsx
201 | // Access the transform facade (read only) through the map facade
202 | const transform = map.transform;
203 |
204 | // Optionally use a clone to have a working transform (detached);
205 | const clonedTransform = map.cloneTransform(); // version unlocked clone..
206 | ```
207 |
208 | The cloned transform can provide the ability to calculate zoom around and other
209 | various viewport calculations in a interaction controlled state.
210 |
211 | ### Available Events
212 |
213 | All the current documented events are accessible in this implementation. All
214 | are available through using the MapEvents component with the prefix 'on', e.g.
215 | onClick, onLoad, onMouseMove, onDrag etc.
216 |
217 | * onStyleLoad
218 | * onResize
219 | * onWebGLContextLost
220 | * onWebGLContextRestored
221 | * onRemove
222 | * onDataLoading
223 | * onRender
224 | * onLoad
225 | * onData
226 | * onError
227 | * onMouseOut
228 | * onMouseDown
229 | * onMouseUp
230 | * onMouseMove
231 | * onTouchStart
232 | * onTouchEnd
233 | * onTouchMove
234 | * onTouchCancel
235 | * onClick
236 | * onDblClick
237 | * onContextMenu
238 | * onMoveStart
239 | * onMove
240 | * onMoveEnd
241 | * onZoomStart
242 | * onZoomEnd
243 | * onZoom
244 | * onBoxZoomCancel
245 | * onBoxZoomEnd
246 | * onBoxZoomStart
247 | * onRotateStart
248 | * onRotateEnd
249 | * onDragStart
250 | * onDragEnd
251 | * onDrag
252 | * onPitch
253 |
254 | Note: This component can be mounted many times in the children of the MapGL
255 | component, enabling you to have many different function interactions depending
256 | on what is mounted. There is support for multiple 'onClick' etc. listeners
257 | using this method.
258 |
259 | ## Controlling move animations
260 |
261 | You can provide new viewport details to the map, and as well have the
262 | opportunity to control the animation. This allows you to control the Camera and
263 | Animation options, as well as customise the usual Mapbox API args.
264 |
265 | ### Supported move animations
266 |
267 | * flyTo
268 | * jumpTo
269 | * panTo
270 | * zoomTo
271 | * easeTo
272 | * rotateTo
273 | * fitBounds
274 | * panTo
275 | * fitScreenCoordinates
276 |
277 | Other possible move control include zoomIn/zoomOut, snapToNorth, resetNorth. Be
278 | cautious using these as you need to anticipate their state.
279 |
280 | ### Usage with move function
281 |
282 | ```jsx
283 | const move = (target) => ({
284 | command: 'flyTo',
285 | args: [
286 | {
287 | ...target, // Standard target viewport
288 | // Additional camera/animation options
289 | speed: 0.2, // Slow it down
290 | curve: 1,
291 | // Control the easing
292 | easing: function(t) {
293 | return t;
294 | }
295 | }
296 | ]
297 | });
298 |
299 | return (
300 |
304 | );
305 | ```
306 |
307 | ### Controlled animation
308 |
309 | Supporting stateless behaviour, this library can use React-Motion or any other
310 | animation prop controled easing/animation library.
311 |
312 | ```jsx
313 |
317 | {({ latitude, longitude }) => }
323 |
324 | ```
325 |
326 | ### Controlling viewport interactions (stateless map viewport)
327 |
328 | If you chose to fully control the viewstate component and control your own
329 | interactions, you can wrap this component in your own interaction component.
330 |
331 | The child context provides access to the read only Map Facade, which supports
332 | read-only project/unproject/transform as well as a cloneTransform etc.
333 |
334 | ```jsx
335 | return (
336 |
340 | this.setState({ viewport })}
342 | />
343 |
344 | );
345 | ```
346 |
347 | ### featureStates
348 |
349 | You can pass the prop of featureState with an array of feature states.
350 |
351 | ```
352 | // References to the feature state
353 | const feature = { source: 'mySource', sourceLayer: 'default', id: '123' };
354 | const state = { selected: true };
355 |
356 | const featureStates = [
357 | { feature, state }
358 | ];
359 |
360 | // Apply to the prop featureStates
361 |
362 | ```
363 |
364 | ### Controlling Attribution
365 |
366 | * attributionControlDisabled (default false)
367 | * logoPosition (default 'bottom-left')
368 | * customAttribution (default null, accepts string|array)
369 |
370 | ### Additional Props for initiation of maps
371 |
372 | In addition to the API offered above, the additional props are exposed for
373 | initiating the map:
374 |
375 | * collectResourceTimingDisabled (default true)
376 | * transformRequest (default null)
377 | * localIdeographFontFamily (default null)
378 | * maxTileCacheSize (default null)
379 | * clickTolerance (default 3)
380 |
381 | ### worldCopyJumpDisabled (Experimental - default false)
382 |
383 | When enabled, the map tracks the pan to another copy of the world and resets
384 | the center. This is to assist emulating the behaviour of Leaflet
385 | world copy jump behaviour. This behaviour will reset the center to the wrapped
386 | center after the end of a move behaviour.
387 |
388 | This can help the projection of your overlays (popups and custom markers etc)
389 | that typically have problems projecting with illegal lng/lat values.
390 |
391 | ### trackResizeContainerDisabled (Experimental - default false)
392 |
393 | When enabled, when the container is resized (opposed to the window), the map
394 | will have a resize() call applied. This can assist where a transition happens
395 | to the map component and it is important to call resize().
396 |
397 | ### crossSourceCollisionsDisabled (default false)
398 |
399 | With the introduction of 0.46.0, Mapbox GL JS support for disabling cross source
400 | collissions has been introduced. Apply this prop to the map to apply the map
401 | option.
402 |
--------------------------------------------------------------------------------
/example/src/example.jsx:
--------------------------------------------------------------------------------
1 | const mapboxgl = require('mapbox-gl');
2 |
3 | mapboxgl.accessToken = 'pk.eyJ1IjoiYWxwYWNhdHJhdmVsIiwiYSI6ImNpazY0aTB6czAwbGhoZ20ycHN2Ynhlc28ifQ.GwAeDuQVIUb4_U1mT-QUig';
4 | const map = new mapboxgl.Map({
5 | container: 'map', // container id
6 | style: 'mapbox://styles/mapbox/streets-v9', // stylesheet location
7 | center: [-74.50, 40], // starting position [lng, lat]
8 | zoom: 9,
9 | });
10 | console.log(map);
11 |
--------------------------------------------------------------------------------
/example/src/index.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import MapGL from '../../src/map';
4 | import MapEvents from '../../src/map-events';
5 |
6 | const mapboxApiAccessToken = process.env.MAPBOX_API_ACCESS_TOKEN;
7 |
8 | const flyTo = (target) => ({
9 | command: 'flyTo',
10 | args: [{
11 | ...target,
12 | // Use animation options, duration etc.
13 | duration: 1000,
14 | curve: 1.8,
15 | }],
16 | });
17 |
18 | const fitBounds = (target) => ({
19 | command: 'fitBounds',
20 | args: [target.bounds, { duration: 0 }]
21 | });
22 |
23 | const resetNorth = (target) => ({
24 | command: 'resetNorth',
25 | args: [{
26 | ...target,
27 | duration: 200,
28 | }],
29 | });
30 |
31 | class Example extends React.Component {
32 | constructor(props, context) {
33 | super(props, context);
34 | this.state = {
35 | loaded: false,
36 | target: {
37 | center: [
38 | 144.9633200,
39 | -37.8140000,
40 | ],
41 | zoom: 5,
42 | },
43 | motion: flyTo,
44 | flex: 1,
45 | featureStates: [],
46 | };
47 |
48 | this._onClick = this._onClick.bind(this);
49 | this._onChangeViewport = this._onChangeViewport.bind(this);
50 | }
51 |
52 | _onChangeViewport(viewport) {
53 | this.setState({ viewport });
54 | }
55 |
56 | _onClick(e) {
57 | // Access features under cursor through safe non-mutable map facade
58 | const features = e.target.queryRenderedFeatures(e.point);
59 | console.log(e, features);
60 | }
61 |
62 | render() {
63 | // Can update center/zoom etc to move
64 | return (
65 |