@carto/kepler.gl 0.0.64 → 0.0.65-alpha.labels.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,673 +1,64 @@
1
- <p align="right">
2
- <a href="https://npmjs.org/package/kepler.gl">
3
- <img src="https://img.shields.io/npm/v/kepler.gl.svg?style=flat" alt="version" />
4
- </a>
5
- <a href="https://travis-ci.com/keplergl/kepler.gl">
6
- <img src="https://api.travis-ci.com/keplergl/kepler.gl.svg?branch=master" alt="build" />
7
- </a>
8
- <a href="https://github.com/keplergl/kepler.gl">
9
- <img src="https://img.shields.io/github/stars/keplergl/kepler.gl.svg?style=flat" alt="stars" />
10
- </a>
11
- <a href='https://opensource.org/licenses/MIT'>
12
- <img src='https://img.shields.io/badge/License-MIT-blue.svg' alt='MIT License' />
13
- </a>
14
- <a href='https://app.fossa.com/projects/custom%2B4458%2Fgithub.com%2Fkeplergl%2Fkepler.gl?ref=badge_shield'>
15
- <img src='https://app.fossa.com/api/projects/custom%2B4458%2Fgithub.com%2Fkeplergl%2Fkepler.gl.svg?type=shield' alt='Fossa' />
16
- </a>
17
- <a href="https://app.netlify.com/sites/keplergl/deploys" alt="Netlify Status">
18
- <img src="https://img.shields.io/endpoint.svg?url=https%3A%2F%2Fdeveloper.oswaldlabs.com%2Fnetlify-status%2F0c9b895c-acd0-43fd-8af7-fe960181b686?style=flat" />
19
- </a>
20
- </p>
1
+ # CARTO fork of [Kepler.gl](http://www.kepler.gl/)
21
2
 
22
- <h1 align="center">
23
- kepler.gl | <a href="http://kepler.gl">Website</a> | <a href="http://kepler.gl/#/demo">Demo App</a> | <a href="https://docs.kepler.gl/">Docs</a>
24
- </h1>
25
- <h3></h3>
3
+ Published as [`@carto/kepler.gl`](https://www.npmjs.com/package/@carto/kepler.gl), used by the Cloud Native app.
26
4
 
27
- [<img width="120" alt="Kepler.gl" src="https://d1a3f4spazzrp4.cloudfront.net/kepler.gl/website/icons/kepler.gl-logo.png">](http://kepler.gl)
5
+ ## Development process
28
6
 
29
- [<img width="600" alt="Kepler.gl Demo" src="https://eng.uber.com/wp-content/uploads/2018/05/image4-3-768x493.png">](http://kepler.gl/#/demo)
7
+ ### Pull request
30
8
 
31
- [Kepler.gl][web] is a data-agnostic, high-performance web-based application for visual exploration of large-scale geolocation data sets. Built on top of [Mapbox GL](https://www.mapbox.com) and [deck.gl](http://uber.github.io/deck.gl/#/), kepler.gl can render millions of points representing thousands of trips and perform spatial aggregations on the fly.
9
+ - Each development should be done in its own feature branch
10
+ - The pull request should be diff-ed with the `main` branch
11
+ - Apart from code changes, the PR should include an entry in the "Not released" section of `CHANGELOG.md` with a link to itself (if the section is not present, re-create it at the top of the file). This facilitates the release process by keeping the changelog always up-to-date with `main`.
32
12
 
33
- Kepler.gl is also a React component that uses [Redux](https://redux.js.org/) to manage its state and data flow. It can be embedded into other React-Redux applications and is highly customizable. For information on how to embed kepler.gl in your app take a look at this step-by-step [tutorial][vis-academy] on vis.academy.
13
+ Ex:
34
14
 
35
- ## Links
15
+ ```md
16
+ ## Not released
36
17
 
37
- - [Website][web]
38
- - [Demo][demo-app]
39
- - [Examples][examples]
40
- - [Get Started][get-started]
41
- - [App User Guide][user-guide]
42
- - [Jupyter Widget User Guide][user-guide-jupyter]
43
- - [Tutorial][vis-academy]
44
- - [Stack Overflow][stack]
45
- - [Contribution Guidelines][contributing]
46
- - [Api Reference][api-reference]
47
- - [Roadmap][roadmap]
18
+ - Support for count aggregation [141](https://github.com/CartoDB/carto-kepler/pull/141)
19
+ ```
48
20
 
49
- ## Env
21
+ - After review, merge into the `main` branch by squashing commits, to keep a clean history.
50
22
 
51
- Use Node 10.15.0 or above, older node versions have not been supported/ tested.
52
- For best results, use [nvm](https://github.com/creationix/nvm) `nvm install`.
23
+ ### Developing with Cloud Native
53
24
 
54
- ## Install kepler.gl
25
+ When developing locally, you can use symlinks to connect your local Cloud Native to your local CARTO Kepler:
55
26
 
56
- Install node (`> 10.15.0`), yarn, and project dependencies
27
+ 1. in carto-kepler: `yarn link`
28
+ 1. in cloud-native: `yarn link @carto/kepler.gl`
29
+ 1. in carto-kepler: `yarn build:watch`
30
+ 1. in cloud-native: `yarn start`
57
31
 
58
- ```sh
59
- npm install --save kepler.gl
60
- // or
61
- yarn add kepler.gl
62
- ```
32
+ ### Dev prerelease
63
33
 
64
- kepler.gl is built upon [mapbox][mapbox]. You will need a [Mapbox Access Token][mapbox-token] to use it.
34
+ To be able to test a dev version of carto-kepler from cloud-native on a remote environment (ex: dedicated environments for QA), you need to publish an alpha version of carto-kepler.
65
35
 
66
- If you don't use a module bundler, it's also fine. Kepler.gl npm package includes precompiled production UMD builds in the [umd folder](https://unpkg.com/kepler.gl/umd).
67
- You can add the script tag to your html file as it follows:
36
+ 1. Switch to the branch you want to publish. You can use any unmerged dev branch, but make sure it's based on the latest `main` to avoid behavior changes outside the branch scope.
37
+ 1. Manually change the version in `package.json`. Use this pattern: `<next-version>-alpha.<feature>`.
68
38
 
69
- ```html
70
- <script src="https://unpkg.com/kepler.gl/umd/keplergl.min.js" />
71
- ```
39
+ Ex: `0.0.47-alpha.custom-markers`
72
40
 
73
- or if you would like, you can load a specific version
41
+ 1. Build the project with `yarn build`, and ensure there is no error.
42
+ 1. Publish the package to NPM as alpha. You need to have the proper rights on the NPM organization.
43
+ ```
44
+ npm publish --tag alpha
45
+ ```
46
+ 1. If the package has been correctly published, then in `cloud-native` install the new version with `yarn add @carto/kepler.gl@<alpha-version-number>`, and open a PR.
74
47
 
75
- ```html
76
- <script src="https://unpkg.com/kepler.gl@0.2.2/umd/keplergl.min.js" />
77
- ```
48
+ If you need to change some things later in the code, you will need to republish. Repeat the process by simply adding a suffix to the version number.
78
49
 
79
- ## Develop kepler.gl
50
+ Ex: `0.0.47-alpha.custom-markers.2`
80
51
 
81
- Take a look at the [development guide][developers] to develop kepler.gl locally.
52
+ ## Stable release process
82
53
 
83
- ## Basic Usage
54
+ 1. Create a branch `release-<next-version>` from the latest changes on `main`.
55
+ 1. Modify the `CHANGELOG.md` file, by creating a new section `<next-version>` and moving contents from "Not released" to it. Keep the empty "Not released" section at the top of the file.
56
+ 1. Increase version in `package.json` to `<next-version>`
57
+ 1. Build the project with `yarn build`, and ensure there is no error.
58
+ 1. Publish to NPM
84
59
 
85
- Here are the basic steps to import kepler.gl into your app. You also take a look at the examples folder. Each example in the folder can be installed and run locally.
60
+ ```
61
+ npm publish --access public
62
+ ```
86
63
 
87
- ### 1. Mount reducer
88
-
89
- Kepler.gl uses Redux to manage its internal state, along with [react-palm][react-palm] middleware to handle side effects.
90
-
91
- You need to add `taskMiddleware` of `react-palm` to your store too. We are actively working on a solution where
92
- `react-palm` will not be required, however it is still a very lightweight side effects management tool that is easier to test than react-thunk.
93
-
94
- ```js
95
- import {createStore, combineReducers, applyMiddleware, compose} from 'redux';
96
- import keplerGlReducer from 'kepler.gl/reducers';
97
- import {enhanceReduxMiddleware} from 'kepler.gl/middleware';
98
-
99
- const initialState = {};
100
- const reducers = combineReducers({
101
- // <-- mount kepler.gl reducer in your app
102
- keplerGl: keplerGlReducer,
103
-
104
- // Your other reducers here
105
- app: appReducer
106
- });
107
-
108
- // using createStore
109
- export default createStore(
110
- reducer,
111
- initialState,
112
- applyMiddleware(
113
- enhanceReduxMiddleware([
114
- /* Add other middlewares here */
115
- ])
116
- )
117
- );
118
- ```
119
-
120
- Or if use enhancer:
121
-
122
- ```js
123
- // using enhancers
124
- const initialState = {};
125
- const middlewares = enhanceReduxMiddleware([
126
- // Add other middlewares here
127
- ]);
128
- const enhancers = [applyMiddleware(...middlewares)];
129
-
130
- export default createStore(reducer, initialState, compose(...enhancers));
131
- ```
132
-
133
- If you mount kepler.gl reducer in another address instead of `keplerGl`, or the kepler.gl reducer is not
134
- mounted at root of your state, you will need to specify the path to it when you mount the component
135
- with the `getState` prop.
136
-
137
- Read more about [Reducers][reducers].
138
-
139
- ### 2. Mount Component
140
-
141
- ```js
142
- import KeplerGl from 'kepler.gl';
143
-
144
- const Map = props => (
145
- <KeplerGl
146
- id="foo"
147
- width={width}
148
- mapboxApiAccessToken={token}
149
- height={height}
150
- />
151
- );
152
- ```
153
-
154
- #### Props
155
-
156
- ##### `id` (String, required)
157
-
158
- - Default: `map`
159
-
160
- The id of this KeplerGl instance. `id` is required if you have multiple
161
- KeplerGl instances in your app. It defines the prop name of the KeplerGl state that is
162
- stored in the KeplerGl reducer. For example, the state of the KeplerGl component with id `foo` is
163
- stored in `state.keplerGl.foo`.
164
-
165
- In case you create multiple kepler.gl instances using the same id, the kepler.gl state defined by the entry will be
166
- overridden by the latest instance and reset to a blank state.
167
-
168
- ##### `mapboxApiAccessToken` (String, required*)
169
-
170
- - Default: `undefined`
171
-
172
-
173
- By default, kepler.gl uses mapbox-gl.js to render its base maps. You can create a free account at [mapbox][mapbox] and create a token at [www.mapbox.com/account/access-tokens][mapbox-token].
174
-
175
- If you replaced kepler.gl default map styles with your own, and they are not Mapbox styles. `mapboxApiAccessToken` will not be reuiqred.
176
-
177
- Read more about [Custom Map Styles][custom-map-styles].
178
-
179
- ##### `getState` (Function, optional)
180
-
181
- - Default: `state => state.keplerGl`
182
-
183
- The path to the root keplerGl state in your reducer.
184
-
185
- ##### `width` (Number, optional)
186
-
187
- - Default: `800`
188
-
189
- Width of the KeplerGl UI.
190
-
191
- ##### `height` (Number, optional)
192
-
193
- - Default: `800`
194
-
195
- ##### `appName` (String, optional)
196
-
197
- - Default: `Kepler.Gl`
198
-
199
- App name displayed in side panel header
200
-
201
- ##### `version` (String, optional)
202
-
203
- - Default: `v1.0`
204
-
205
- version displayed in side panel header
206
-
207
- ##### `onSaveMap` (Function, optional)
208
-
209
- - Default: `undefined`
210
-
211
- Action called when click Save Map Url in side panel header.
212
-
213
- ##### `onViewStateChange` (Function, optional)
214
-
215
- - Default: `undefined`
216
- - Parameter: `viewState` - An updated view state object containing parameters such as longitude, latitude, zoom etc
217
-
218
- Action triggered when map viewport is updated.
219
-
220
- ##### `getMapboxRef(mapbox, index)` (Function, optional)
221
-
222
- - Default: `undefined`
223
-
224
- Function called when `KeplerGL` adds or removes a `MapContainer` component having an inner Mapbox map.
225
-
226
- The `mapbox` argument is an [`InteractiveMap`](https://uber.github.io/react-map-gl/#/Documentation/api-reference/interactive-map) when added or `null` when removed.
227
-
228
- The `index` argument is 0 for a single map or 1 for an additional map (since `KeplerGL` supports an optional split map view).
229
-
230
- ##### `actions` (Object, optional)
231
-
232
- - Default: `{}`
233
-
234
- Actions creators to replace default kepler.gl action creator. Only use custom action when you want to modify action payload.
235
-
236
- ##### `mint` (Boolean, optional)
237
-
238
- - Default: `true`
239
-
240
- Whether to load a fresh empty state when component is mounted. when parse `mint: true` kepler.gl component will always load a fresh state when re-mount the same component, state inside this component will be destroyed once its unmounted.
241
- By Parsing `mint: false` kepler.gl will keep the component state in the store even when it is unmounted, and use it as initial state when re-mounted again. This is useful when mounting kepler.gl in a modal, and keep the same map when re-open.
242
-
243
- Read more about [Components][components].
244
-
245
- ##### `theme` (Object | String, optional)
246
-
247
- - default: `null`
248
-
249
- One of `"dark"`, `"light"` or `"base"`
250
- You can pass theme name or object used to customize Kepler.gl style. Kepler.gl provide an `'light'` theme besides the default 'dark' theme. When pass in a theme object Kepler.gl will use the value passed as input to override values from [theme](https://github.com/keplergl/kepler.gl/blob/master/src/styles/base.js).
251
-
252
- Read more about [Custom Theme][custom-theme]
253
-
254
- #### `mapboxApiUrl` (String, optional)
255
-
256
- - Default: `https://api.mapbox.com`
257
-
258
- If you are using your own mapbox tile server, you can pass in your own tile server api url.
259
-
260
- #### `mapStylesReplaceDefault` (Boolean, optional)
261
-
262
- - Default: `false`
263
-
264
- kepler.gl provide 4 map styles to choose from. Pass `true` if you want to supply your own `mapStyles`. See Below.
265
-
266
- #### `mapStyles` (Array, optional)
267
-
268
- - Default: `[]`
269
-
270
- You can supply additional map styles to be displayed in [map style selection panel](https://github.com/keplergl/kepler.gl/blob/master/docs/user-guides/f-map-styles/1-base-map-styles.md). By default, additional map styles will be added to default map styles. If pass `mapStylesReplaceDefault: true`, they will replace the default ones. kepler.gl will attempt to group layers of your style based on its `id` naming convention and use it to allow toggle visibility of [base map layers](https://github.com/keplergl/kepler.gl/blob/master/docs/user-guides/f-map-styles/2-map-layers.md). Supply your own `layerGroups` to override default for more accurate layer grouping.
271
-
272
- Each `mapStyles` should has the following properties:
273
-
274
- - `id` (String, required) unique string that should **not** be one of these reserved `dark` `light` `muted`. `muted_night`
275
- - `label` (String, required) name to be displayed in map style selection panel
276
- - `url` (String, required) mapbox style url or a url pointing to the map style json object written in [Mapbox GL Style Spec](https://docs.mapbox.com/mapbox-gl-js/style-spec/).
277
- - `icon` (String, optional) image icon of the style, it can be a url, or an [image data url](https://flaviocopes.com/data-urls/#how-does-a-data-url-look)
278
- - `layerGroups` (Array, optional)
279
-
280
- ```js
281
- const mapStyles = [
282
- {
283
- id: 'my_dark_map',
284
- label: 'Dark Streets 9',
285
- url: 'mapbox://styles/mapbox/dark-v9',
286
- icon: `${apiHost}/styles/v1/mapbox/dark-v9/static/-122.3391,37.7922,9.19,0,0/400x300?access_token=${accessToken}&logo=false&attribution=false`,
287
- layerGroups: [
288
- {
289
- slug: 'label',
290
- filter: ({id}) => id.match(/(?=(label|place-|poi-))/),
291
- defaultVisibility: true
292
- },
293
- {
294
- // adding this will keep the 3d building option
295
- slug: '3d building',
296
- filter: () => false,
297
- defaultVisibility: false
298
- }
299
- ]
300
- }
301
- ];
302
- ```
303
-
304
- Read more about [Custom Map Styles][custom-map-styles].
305
-
306
- #### `initialUiState` (object, optional)
307
-
308
- - Default: `undefined`
309
-
310
- Intial UI State applied to uiState reducer, value will be shallow merged with default [`INITIAL_UI_STATE`](https://docs.kepler.gl/docs/api-reference/reducers/ui-state#initial_ui_state)
311
-
312
- #### `localeMessages` (object, optional)
313
-
314
- - Default: `undefined` Modify default translation or add new translation
315
-
316
- Read more about [Localization][localization].
317
-
318
- ### 3. Dispatch custom actions to `keplerGl` reducer.
319
-
320
- One advantage of using the reducer over React component state to handle keplerGl state is the flexibility
321
- to customize its behavior. If you only have one `KeplerGl` instance in your app or never intend to dispatch actions to KeplerGl from outside the component itself,
322
- you don’t need to worry about forwarding dispatch and can move on to the next section. But life is full of customizations, and we want to make yours as enjoyable as possible.
323
-
324
- There are multiple ways to dispatch actions to a specific `KeplerGl` instance.
325
-
326
- - In the root reducer, with reducer updaters.
327
-
328
- Each action is mapped to a reducer updater in kepler.gl. You can import the reducer updater corresponding to a specific action, and call it with the previous state and action payload to get the updated state.
329
- e.g. `updateVisDataUpdater` is the updater for `ActionTypes.UPDATE_VIS_DATA` (take a look at each reducer `reducers/vis-state.js` for action to updater mapping).
330
- Here is an example how you can listen to an app action `QUERY_SUCCESS` and call `updateVisDataUpdater` to load data into Kepler.Gl.
331
-
332
- ```js
333
- import keplerGlReducer, {visStateUpdaters} from 'kepler.gl/reducers';
334
-
335
- // Root Reducer
336
- const reducers = combineReducers({
337
- keplerGl: keplerGlReducer,
338
-
339
- app: appReducer
340
- });
341
-
342
- const composedReducer = (state, action) => {
343
- switch (action.type) {
344
- case 'QUERY_SUCCESS':
345
- return {
346
- ...state,
347
- keplerGl: {
348
- ...state.keplerGl,
349
-
350
- // 'map' is the id of the keplerGl instance
351
- map: {
352
- ...state.keplerGl.map,
353
- visState: visStateUpdaters.updateVisDataUpdater(
354
- state.keplerGl.map.visState,
355
- {datasets: action.payload}
356
- )
357
- }
358
- }
359
- };
360
- }
361
- return reducers(state, action);
362
- };
363
-
364
- export default composedReducer;
365
- ```
366
-
367
- Read more about [using updaters to modify kepler.gl state][using-updaters]
368
-
369
- - Using redux `connect`
370
-
371
- You can add a dispatch function to your component that dispatches actions to a specific `keplerGl` component,
372
- using connect.
373
-
374
- ```js
375
- // component
376
- import KeplerGl from 'kepler.gl';
377
-
378
- // action and forward dispatcher
379
- import {toggleFullScreen, forwardTo} from 'kepler.gl/actions';
380
- import {connect} from 'react-redux';
381
-
382
- const MapContainer = props => (
383
- <div>
384
- <button onClick={() => props.keplerGlDispatch(toggleFullScreen())}/>
385
- <KeplerGl
386
- id="foo"
387
- />
388
- </div>
389
- )
390
-
391
- const mapStateToProps = state => state
392
- const mapDispatchToProps = (dispatch, props) => ({
393
- dispatch,
394
- keplerGlDispatch: forwardTo(‘foo’, dispatch)
395
- });
396
-
397
- export default connect(
398
- mapStateToProps,
399
- mapDispatchToProps
400
- )(MapContainer);
401
- ```
402
-
403
- - Wrap action payload
404
-
405
- You can also simply wrap an action into a forward action with the `wrapTo` helper
406
-
407
- ```js
408
- // component
409
- import KeplerGl from 'kepler.gl';
410
-
411
- // action and forward dispatcher
412
- import {toggleFullScreen, wrapTo} from 'kepler.gl/actions';
413
-
414
- // create a function to wrapper action payload to 'foo'
415
- const wrapToMap = wrapTo('foo');
416
- const MapContainer = ({dispatch}) => (
417
- <div>
418
- <button onClick={() => dispatch(wrapToMap(toggleFullScreen())} />
419
- <KeplerGl
420
- id="foo"
421
- />
422
- </div>
423
- );
424
-
425
- ```
426
-
427
- Read more about [forward dispatching actions][forward-actions]
428
-
429
- ### 4. Customize style.
430
-
431
- Kepler.gl implements css styling using [Styled-Components](https://www.styled-components.com/). By using said framework Kepler.gl offers the ability to customize its style/theme using the following approaches:
432
-
433
- - Passing a Theme prop
434
- - Styled-Components ThemeProvider
435
-
436
- The available properties to customize are listed here [theme](https://github.com/keplergl/kepler.gl/blob/master/src/styles/base.js).
437
-
438
- [Custom theme example](https://github.com/keplergl/kepler.gl/tree/master/examples/custom-theme).
439
-
440
- #### Passing a Theme prop.
441
-
442
- You can customize Kepler.gl theme by passing a **theme** props to Kepler.gl react component as it follows:
443
-
444
- ```javascript
445
- const white = '#ffffff';
446
- const customTheme = {
447
- sidePanelBg: white,
448
- titleTextColor: '#000000',
449
- sidePanelHeaderBg: '#f7f7F7',
450
- subtextColorActive: '#2473bd'
451
- };
452
-
453
- return (
454
- <KeplerGl
455
- mapboxApiAccessToken={MAPBOX_TOKEN}
456
- id="map"
457
- width={800}
458
- height={800}
459
- theme={customTheme}
460
- />
461
- );
462
- ```
463
-
464
- As you can see the customTheme object defines certain properties which will override Kepler.gl default style rules.
465
-
466
- #### Styled-Components Theme Provider.
467
-
468
- In order to customize Kepler.gl theme using [ThemeProvider](https://www.styled-components.com/docs/api#themeprovider) you can simply wrap Kepler.gl using ThemeProvider as it follows:
469
-
470
- ```javascript
471
- import {ThemeProvider} from 'styled-components';
472
-
473
- const white = '#ffffff';
474
- const customTheme = {
475
- sidePanelBg: white,
476
- titleTextColor: '#000000',
477
- sidePanelHeaderBg: '#f7f7F7',
478
- subtextColorActive: '#2473bd'
479
- };
480
-
481
- return (
482
- <ThemeProvider theme={customTheme}>
483
- <KeplerGl
484
- mapboxApiAccessToken={MAPBOX_TOKEN}
485
- id="map"
486
- width={800}
487
- height={800}
488
- />
489
- </ThemeProvider>
490
- );
491
- ```
492
-
493
- ### 5. Render Custom UI components.
494
-
495
- Everyone wants the flexibility to render custom kepler.gl components. Kepler.gl has a dependency injection system that allow you to inject
496
- components to KeplerGl replacing existing ones. All you need to do is to create a component factory for the one you want to replace, import the original component factory
497
- and call `injectComponents` at the root component of your app where `KeplerGl` is mounted.
498
- Take a look at `examples/demo-app/src/app.js` and see how it renders a custom side panel header in kepler.gl
499
-
500
- ```javascript
501
- import {injectComponents, PanelHeaderFactory} from 'kepler.gl/components';
502
-
503
- // define custom header
504
- const CustomHeader = () => <div>My kepler.gl app</div>;
505
- const myCustomHeaderFactory = () => CustomHeader;
506
-
507
- // Inject custom header into Kepler.gl, replacing default
508
- const KeplerGl = injectComponents([
509
- [PanelHeaderFactory, myCustomHeaderFactory]
510
- ]);
511
-
512
- // render KeplerGl, it will render your custom header instead of the default
513
- const MapContainer = () => (
514
- <div>
515
- <KeplerGl id="foo" />
516
- </div>
517
- );
518
- ```
519
-
520
- Using `withState` helper to add reducer state and actions to customized component as additional props.
521
-
522
- ```js
523
- import {
524
- withState,
525
- injectComponents,
526
- PanelHeaderFactory
527
- } from 'kepler.gl/components';
528
- import {visStateLens} from 'kepler.gl/reducers';
529
-
530
- // custom action wrap to mounted instance
531
- const addTodo = text =>
532
- wrapTo('map', {
533
- type: 'ADD_TODO',
534
- text
535
- });
536
-
537
- // define custom header
538
- const CustomHeader = ({visState, addTodo}) => (
539
- <div onClick={() => addTodo('hello')}>{`${
540
- Object.keys(visState.datasets).length
541
- } dataset loaded`}</div>
542
- );
543
-
544
- // now CustomHeader will receive `visState` and `addTodo` as additional props.
545
- const myCustomHeaderFactory = () =>
546
- withState(
547
- // keplerGl state lenses
548
- [visStateLens],
549
- // customMapStateToProps
550
- headerStateToProps,
551
- // actions
552
- {addTodo}
553
- )(CustomHeader);
554
- ```
555
-
556
- Read more about [replacing UI component][replace-ui-component]
557
-
558
- ### 6. How to add data to map
559
-
560
- To interact with a kepler.gl instance and add new data to it, you can dispatch the **`addDataToMap`** action from anywhere inside your app. It adds a dataset or multiple datasets to a kepler.gl instance and updates the full configuration (mapState, mapStyle, visState).
561
-
562
- #### Parameters
563
-
564
- - `data` **[Object][40]** **\*required**
565
- - `datasets` **([Array][41]&lt;[Object][40]> | [Object][40])** **\*required** datasets can be a dataset or an array of datasets
566
- Each dataset object needs to have `info` and `data` property.
567
- - `datasets.info` **[Object][40]** \-info of a dataset
568
- - `datasets.info.id` **[string][42]** id of this dataset. If config is defined, `id` should matches the `dataId` in config.
569
- - `datasets.info.label` **[string][42]** A display name of this dataset
570
- - `datasets.data` **[Object][40]** **\*required** The data object, in a tabular format with 2 properties `fields` and `rows`
571
- - `datasets.data.fields` **[Array][41]&lt;[Object][40]>** **\*required** Array of fields,
572
- - `datasets.data.fields.name` **[string][42]** **\*required** Name of the field,
573
- - `datasets.data.rows` **[Array][41]&lt;[Array][41]>** **\*required** Array of rows, in a tabular format with `fields` and `rows`
574
- - `options` **[Object][40]**
575
-
576
- - `options.centerMap` **[boolean][43]** `default: true` if `centerMap` is set to `true` kepler.gl will place the map view within the data points boundaries
577
- - `options.readOnly` **[boolean][43]** `default: false` if `readOnly` is set to `true`
578
- the left setting panel will be hidden
579
- - `options.keepExistingConfig` **[boolean][43]** `default: false` whether to keep exiting map config, including layers, filters and splitMaps.
580
-
581
- - `config` **[Object][40]** this object will contain the full kepler.gl instance configuration {mapState, mapStyle, visState}
582
-
583
- Kepler.gl provides an easy API `KeplerGlSchema.getConfigToSave` to generate a json blob of the current kepler instance configuration.
584
-
585
- #### Examples
586
-
587
- ```javascript
588
- // app.js
589
- import {addDataToMap} from 'kepler.gl/actions';
590
-
591
- const sampleTripData = {
592
- fields: [
593
- {name: 'tpep_pickup_datetime', format: 'YYYY-M-D H:m:s', type: 'timestamp'},
594
- {name: 'pickup_longitude', format: '', type: 'real'},
595
- {name: 'pickup_latitude', format: '', type: 'real'}
596
- ],
597
- rows: [
598
- ['2015-01-15 19:05:39 +00:00', -73.99389648, 40.75011063],
599
- ['2015-01-15 19:05:39 +00:00', -73.97642517, 40.73981094],
600
- ['2015-01-15 19:05:40 +00:00', -73.96870422, 40.75424576]
601
- ]
602
- };
603
-
604
- const sampleConfig = {
605
- visState: {
606
- filters: [
607
- {
608
- id: 'me',
609
- dataId: 'test_trip_data',
610
- name: 'tpep_pickup_datetime',
611
- type: 'timeRange',
612
- enlarged: true
613
- }
614
- ]
615
- }
616
- };
617
-
618
- this.props.dispatch(
619
- addDataToMap({
620
- datasets: {
621
- info: {
622
- label: 'Sample Taxi Trips in New York City',
623
- id: 'test_trip_data'
624
- },
625
- data: sampleTripData
626
- },
627
- option: {
628
- centerMap: true,
629
- readOnly: false
630
- },
631
- config: sampleConfig
632
- })
633
- );
634
- ```
635
-
636
- Read more about [addDataToMap](./docs/api-reference/actions/actions.md#adddatatomap) and [Saving and loading maps with schema manager][saving-loading-w-schema].
637
-
638
- [contributing]: contributing/README.md
639
- [demo-app]: http://kepler.gl/#/demo
640
- [github]: https://github.com/keplergl/kepler.gl
641
- [github-pr]: https://help.github.com/articles/creating-a-pull-request/
642
- [mapbox]: https://www.mapbox.com
643
- [mapbox-token]: https://www.mapbox.com/help/define-access-token/
644
- [developers]: contributing/DEVELOPERS.md
645
- [examples]: https://github.com/keplergl/kepler.gl/tree/master/examples
646
- [react-palm]: https://github.com/btford/react-palm
647
- [roadmap]: https://github.com/keplergl/kepler.gl/wiki/Kepler.gl-2019-Roadmap
648
- [stack]: https://stackoverflow.com/questions/tagged/kepler.gl
649
- [web]: http://www.kepler.gl/
650
- [vis-academy]: http://vis.academy/#/kepler.gl/
651
- [user-guide]: docs/user-guides/README.md
652
- [user-guide-jupyter]: docs/keplergl-jupyter/README.md
653
- [api-reference]: docs/api-reference/README.md
654
- [get-started]: ./docs/api-reference/get-started.md
655
- [reducers]: docs/api-reference/reducers/README.md
656
- [components]: docs/api-reference/components/README.md
657
- [custom-theme]: docs/api-reference/custom-theme/README.md
658
- [reducers]: docs/api-reference/reducers/README.md
659
- [actions-updaters]: docs/api-reference/actions/README.md
660
- [processors]: docs/api-reference/processors/README.md
661
- [schemas]: docs/api-reference/schemas/README.md
662
- [using-updaters]: ./docs/api-reference/advanced-usages/using-updaters.md
663
- [custom-map-styles]: ./docs/api-reference/advanced-usages/custom-map-styles.md
664
- [forward-actions]: ./docs/api-reference/advanced-usages/forward-actions.md
665
- [replace-ui-component]: ./docs/api-reference/advanced-usages/replace-ui-component.md
666
- [saving-loading-w-schema]: ./docs/api-reference/advanced-usages/saving-loading-w-schema.md
667
- [localization]: ./docs/api-reference/localization/README.md
668
- [40]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
669
- [41]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
670
- [42]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
671
- [43]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
672
- [44]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
673
- [45]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
64
+ 1. Finally, keep the `main` branch up-to-date with the release. Commit the changes (`git commit -am "release <next-version>"`), push, open a PR, ask for review and merge.