Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
[Doc] Add example using none mapbox base map (#1440)
Shan He14c35fc048a7
diff --git a/README.md b/README.mdindex cc6c2bc1e..479852804 100644--- a/README.md+++ b/README.md@@ -165,11 +165,16 @@ stored in `state.keplerGl.foo`.In case you create multiple kepler.gl instances using the same id, the kepler.gl state defined by the entry will beoverridden by the latest instance and reset to a blank state.-##### `mapboxApiAccessToken` (String, required)+##### `mapboxApiAccessToken` (String, required*)- Default: `undefined`-You can create a free account at [mapbox][mapbox] and create a token at [www.mapbox.com/account/access-tokens][mapbox-token]++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].++If you replaced kepler.gl default map styles with your own, and they are not Mapbox styles. `mapboxApiAccessToken` will not be reuiqred.++Read more about [Custom Map Styles][custom-map-styles].##### `getState` (Function, optional)@@ -268,7 +273,7 @@ Each `mapStyles` should has the following properties:- `id` (String, required) unique string that should **not** be one of these reserved `dark` `light` `muted`. `muted_night`- `label` (String, required) name to be displayed in map style selection panel-- `url` (String, required) mapbox style url or a url pointing to the map style json object+- `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/).- `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)- `layerGroups` (Array, optional)@@ -296,12 +301,20 @@ const mapStyles = [];```+Read more about [Custom Map Styles][custom-map-styles].+#### `initialUiState` (object, optional)- Default: `undefined`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)+#### `localeMessages` (object, optional)++- Default: `undefined` Modify default translation or add new translation++Read more about [Localization][localization].+### 3. Dispatch custom actions to `keplerGl` reducer.One advantage of using the reducer over React component state to handle keplerGl state is the flexibility@@ -647,9 +660,11 @@ Read more about [addDataToMap](./docs/api-reference/actions/actions.md#adddatato[processors]: docs/api-reference/processors/README.md[schemas]: docs/api-reference/schemas/README.md[using-updaters]: ./docs/api-reference/advanced-usages/using-updaters.md+[custom-map-styles]: ./docs/api-reference/advanced-usages/custom-map-styles.md[forward-actions]: ./docs/api-reference/advanced-usages/forward-actions.md[replace-ui-component]: ./docs/api-reference/advanced-usages/replace-ui-component.md[saving-loading-w-schema]: ./docs/api-reference/advanced-usages/saving-loading-w-schema.md+[localization]: ./docs/api-reference/localization/README.md[40]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object[41]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array[42]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Stringdiff --git a/docs/api-reference/README.md b/docs/api-reference/README.mdindex 88e865ef5..20e38a8e9 100644--- a/docs/api-reference/README.md+++ b/docs/api-reference/README.md@@ -19,6 +19,7 @@- [Saving and loading maps with schema manager](./advanced-usages/saving-loading-w-schema.md)- [Replace UI component](./advanced-usages/replace-ui-component.md)- [Custom Mapbox Host](./advanced-usages/custom-mapbox-host.md)+ - [Custom Map Style](./advanced-usages/custom-map-style.md)- [Localization](./localization/README.md)- APIdiff --git a/docs/api-reference/advanced-usages/custom-map-styles.md b/docs/api-reference/advanced-usages/custom-map-styles.mdnew file mode 100644index 000000000..a12ae5ed7--- /dev/null+++ b/docs/api-reference/advanced-usages/custom-map-styles.md@@ -0,0 +1,179 @@+# Using kepler.gl with basemap services other than Mapbox++By default, kepler.gl uses mapbox-gl.js to render its base maps, 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).++++You can custom kepler.gl to use other base map services, by passing in style.json written in [Mapbox GL Style Spec](https://docs.mapbox.com/mapbox-gl-js/style-spec/). With custom style.json kepler.gl can render base map independent of mapbox vector tile service.+++For instance. there is a example [style.json](https://raw.githubusercontent.com/heshan0131/kepler.gl-data/master/style/basic.json). It points to the tile server described in the `sources` field.++```json+ "sources": {+ "openmaptiles": {+ "url": "https://api.maptiler.com/tiles/v3/tiles.json?key=xxxx",+ "type": "vector"+ }+ }+```++### 1. The `mapStyle` object.+Your custom map style should be an object as below+```js+// custom map style+{+ id: 'voyager',+ label: 'Voyager',+ url: 'https://api.maptiler.com/maps/voyager/style.json?key=xxxx',+ icon: 'https://api.maptiler.com/maps/voyager/256/0/0/0.png?key=xxx',+ layerGroups: [+ {+ slug: 'label',+ filter: ({id}) => id.match(/(?=(label|place-|poi-))/),+ defaultVisibility: true+ },+ {+ slug: 'road',+ filter: ({id}) => id.match(/(?=(road|railway|tunnel|street|bridge))(?!.*label)/),+ defaultVisibility: true+ }+ ]+}+```++__style properties__++- `id` (String, required) unique string.+- `label` (String, required) name to be displayed in map style selection panel+- `url` (String, required) a url pointing to the map style json object written in [Mapbox GL Style Spec](https://docs.mapbox.com/mapbox-gl-js/style-spec/).+- `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)+- `layerGroups` (Array, optional) Supply your own `layerGroups` to override default for more accurate layer grouping. When `undefined` 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).++### 2. Two Ways to supply kepler.gl with custom base map styles+++#### Option 1. `mapStyles` prop+Pass `mapStyles` and `mapStylesReplaceDefault` prop to `KeplerGl` component.++```js+const mapStyles = [{+ id: 'voyager',+ label: 'Voyager',+ url: 'https://api.maptiler.com/maps/voyager/style.json?key=xxxx',+ icon: 'https://api.maptiler.com/maps/voyager/256/0/0/0.png?key=xxx'+}];++const App = () => (+ <KeplerGl+ mapboxApiAccessToken=""+ mapStyles={mapStyles}+ mapStylesReplaceDefault={true}+ id="map"+ />+)+```++- `mapStyles` (Array) array of custom map styles.+- `mapStylesReplaceDefault` (Boolean) pass `true` if you want to replace all default kepler.gl base map options.+- `mapboxApiAccessToken`. Optional if `mapStylesReplaceDefault` is `true` and your `mapStyles` does not use Mapbox services++#### Option 2. Reducer `initialState`+Pass custom `mapStyles` to kepler.gl `mapStyle` reducer using the `initialState` plugin. And set default style by passing `styleType`.++This method is demoed in the example app [Custom Map Style](https://github.com/keplergl/kepler.gl/tree/master/examples/custom-map-style)++```js+const customizedKeplerGlReducer = keplerGlReducer.initialState({+ mapStyle: {+ mapStyles: {+ voyager: {+ id: 'voyager',+ label: 'Voyager',+ url: 'https://api.maptiler.com/maps/voyager/style.json?key=xxxx',+ icon: 'https://api.maptiler.com/maps/voyager/256/0/0/0.png?key=xxx'+ },+ terrain: {+ id: 'terrain',+ label: 'Outdoor',+ url: 'https://api.maptiler.com/maps/outdoor/style.json?key=xxx',+ icon: 'https://openmaptiles.org/img/styles/terrain.jpg',+ layerGroups: [+ {+ slug: 'label',+ filter: ({id}) => id.match(/(?=(label|place-|poi-))/),+ defaultVisibility: true+ },+ {+ slug: 'road',+ filter: ({id}) => id.match(/(?=(road|railway|tunnel|street|bridge))(?!.*label)/),+ defaultVisibility: true+ }+ ]+ }+ },+ // Set initial map style+ styleType: 'voyager'+ }+});++```+- `mapStyles` (Object) - `id` as key, and `style` as value.+- `styleType` (string) - Initial map style.++__Which option is for me?__ If you want to replace all basemap styles, we recommends __Option 2__. So you can also set the initial style with `styleType`. If you are adding more options as basemaps, __Option 1__ is ideal.++### 3. `mapboxApiAccessToken`+If your map styles are not using Mapbox services, and you replaced all kepler.gl default map styles. `mapboxApiAccessToken` will not be required in `KeplerGl` component.+++#### 4. `DEFAULT_LAYER_GROUPS`++If `layerGroups` is not suppied, kepler.gl uses the default layer groups below.+++```js+export const DEFAULT_LAYER_GROUPS = [+ {+ slug: 'label',+ filter: ({id}) => id.match(/(?=(label|place-|poi-))/),+ defaultVisibility: true+ },+ {+ slug: 'road',+ filter: ({id}) => id.match(/(?=(road|railway|tunnel|street|bridge))(?!.*label)/),+ defaultVisibility: true+ },+ {+ slug: 'border',+ filter: ({id}) => id.match(/border|boundaries/),+ defaultVisibility: false+ },+ {+ slug: 'building',+ filter: ({id}) => id.match(/building/),+ defaultVisibility: true+ },+ {+ slug: 'water',+ filter: ({id}) => id.match(/(?=(water|stream|ferry))/),+ defaultVisibility: true+ },+ {+ slug: 'land',+ filter: ({id}) => id.match(/(?=(parks|landcover|industrial|sand|hillshade))/),+ defaultVisibility: true+ },+ {+ slug: '3d building',+ filter: () => false,+ defaultVisibility: false+ }+];+```+++#### 5. Geocoder+++####\ No newline at end of filediff --git a/examples/README.md b/examples/README.mdindex 0183722c8..cfa2eabbc 100644--- a/examples/README.md+++ b/examples/README.md@@ -8,29 +8,37 @@ To start each example, cd into the folder then run:yarn && yarn start```-- ### [demo-app][demo-app]+- ### [Demo App][demo-app]kepler.gl as a single page app, loading sample maps from remote url, saving map data to dropbox. This is also the source code of kepler.gl/#/demo.-- ### [open-modal][open-modal]+- ### [Open Modal][open-modal]Open kepler.gl in a modal.-- ### [custom-reducer][custom-reducer]+- ### [Custom Reducer][custom-reducer]Customize kepler.gl reducer initial state, adding more actions using plugin.-- ### [umd-client][umd-client]+- ### [umd client][umd-client]A single html file loading kepler.gl-- ### [replace-component][replace-component]- Example showing how to replace kepler.gl default components using `injectComponents` method.+- ### [Replace UI Component][replace-component]+ Example showing how to replace kepler.gl default ui components using `injectComponents` method.-- ### [custom-theme][custom-theme]- Customize kepler.gl theme by override current style properties.+- ### [Custom theme][custom-theme]+ Customize kepler.gl theme by override default style properties.+- ### [Node App][node-app]+ Embed Kepler.gl in a node/express/webpack application.+- ### [Custom map style][custom-map-style]++ Demo how to use kepler.gl with other basemap services other than Mapbox.[custom-reducer]: custom-reducer/README.md[demo-app]: demo-app/README.md+[node-app]: node-app/README.md+[open-modal]: open-modal/README.md[umd-client]: umd-client/README.md[replace-component]: replace-component/README.md[custom-theme]: custom-theme/README.md+[custom-map-style]: custom-map-style/README.mddiff --git a/examples/custom-map-style/.babelrc b/examples/custom-map-style/.babelrcnew file mode 100644index 000000000..8d40400c0--- /dev/null+++ b/examples/custom-map-style/.babelrc@@ -0,0 +1,9 @@+{+ "presets": [+ "@babel/preset-env",+ "@babel/preset-react"+ ],+ "plugins": [+ "@babel/plugin-proposal-class-properties"+ ]+}diff --git a/examples/custom-map-style/README.md b/examples/custom-map-style/README.mdnew file mode 100644index 000000000..c76dd3d71--- /dev/null+++ b/examples/custom-map-style/README.md@@ -0,0 +1,30 @@+# Custom Map Style++++Demo how to use kepler.gl with other basemap services other than Mapbox.++Read more about [Custom Map Style][custom-map-styles]+++### Run Example+#### 1. Install++```sh+npm install+```++or++```sh+yarn+```++#### 2. Start the app++```sh+npm start+```+++[custom-map-styles]: ./docs/api-reference/advanced-usages/custom-map-styles.md\ No newline at end of filediff --git a/examples/custom-map-style/index.html b/examples/custom-map-style/index.htmlnew file mode 100644index 000000000..bff1cb9df--- /dev/null+++ b/examples/custom-map-style/index.html@@ -0,0 +1,15 @@+<!doctype html>+<html>+ <head>+ <meta charset='UTF-8' />+ <title>kepler.gl demo</title>+ <link rel="stylesheet" href="//d1a3f4spazzrp4.cloudfront.net/kepler.gl/uber-fonts/4.0.0/superfine.css">+ <link href="//api.tiles.mapbox.com/mapbox-gl-js/v1.1.1/mapbox-gl.css" rel="stylesheet">+ <style type="text/css">+ body {margin: 0; padding: 0; overflow: hidden;}+ </style>+ </head>+ <body>+ <script src='bundle.js'></script>+ </body>+</html>diff --git a/examples/custom-map-style/package.json b/examples/custom-map-style/package.jsonnew file mode 100644index 000000000..e1cd85096--- /dev/null+++ b/examples/custom-map-style/package.json@@ -0,0 +1,29 @@+{+ "scripts": {+ "start": "webpack-dev-server --progress --hot --open",+ "start-local": "webpack-dev-server --env.es6 --progress --hot --open"+ },+ "dependencies": {+ "global": "^4.3.0",+ "kepler.gl": "^2.4.0",+ "react": "^16.8.4",+ "react-dom": "^16.8.4",+ "react-palm": "^3.3.6",+ "react-redux": "^7.1.3",+ "react-virtualized": "^9.21.0",+ "redux-actions": "^2.2.1",+ "styled-components": "^4.1.3"+ },+ "devDependencies": {+ "@babel/core": "^7.0.0",+ "@babel/plugin-proposal-class-properties": "^7.3.0",+ "@babel/preset-env": "^7.0.0",+ "@babel/preset-react": "^7.0.0",+ "babel-loader": "^8.0.0",+ "webpack": "^4.29.0",+ "webpack-cli": "^3.2.1",+ "webpack-dev-middleware": "^3.5.1",+ "webpack-dev-server": "^3.1.14",+ "webpack-hot-middleware": "^2.24.3"+ }+}\ No newline at end of filediff --git a/examples/custom-map-style/src/app.js b/examples/custom-map-style/src/app.jsnew file mode 100644index 000000000..17d2a8731--- /dev/null+++ b/examples/custom-map-style/src/app.js@@ -0,0 +1,53 @@+// Copyright (c) 2021 Uber Technologies, Inc.+//+// Permission is hereby granted, free of charge, to any person obtaining a copy+// of this software and associated documentation files (the "Software"), to deal+// in the Software without restriction, including without limitation the rights+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+// copies of the Software, and to permit persons to whom the Software is+// furnished to do so, subject to the following conditions:+//+// The above copyright notice and this permission notice shall be included in+// all copies or substantial portions of the Software.+//+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+// THE SOFTWARE.++import React from 'react';+import {connect} from 'react-redux';+import KeplerGl from 'kepler.gl';+import AutoSizer from 'react-virtualized/dist/commonjs/AutoSizer';++const localeMessages = {+ en: {+ mapLayers: {+ terrain: 'Terrain'+ }+ }+};++const App = () => (+ <div style={{position: 'absolute', width: '100%', height: '100%'}}>+ <AutoSizer>+ {({height, width}) => (+ <KeplerGl+ mapboxApiAccessToken=""+ id="map"+ width={width}+ height={height}+ localeMessages={localeMessages}+ />+ )}+ </AutoSizer>+ </div>+);++const mapStateToProps = state => state;+const dispatchToProps = dispatch => ({dispatch});++export default connect(mapStateToProps, dispatchToProps)(App);diff --git a/examples/custom-map-style/src/main.js b/examples/custom-map-style/src/main.jsnew file mode 100644index 000000000..da62dff4a--- /dev/null+++ b/examples/custom-map-style/src/main.js@@ -0,0 +1,34 @@+// Copyright (c) 2021 Uber Technologies, Inc.+//+// Permission is hereby granted, free of charge, to any person obtaining a copy+// of this software and associated documentation files (the "Software"), to deal+// in the Software without restriction, including without limitation the rights+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+// copies of the Software, and to permit persons to whom the Software is+// furnished to do so, subject to the following conditions:+//+// The above copyright notice and this permission notice shall be included in+// all copies or substantial portions of the Software.+//+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+// THE SOFTWARE.++import React from 'react';+import document from 'global/document';+import {Provider} from 'react-redux';+import {render} from 'react-dom';+import store from './store';+import App from './app';++const Root = () => (+ <Provider store={store}>+ <App />+ </Provider>+);++render(<Root />, document.body.appendChild(document.createElement('div')));diff --git a/examples/custom-map-style/src/store.js b/examples/custom-map-style/src/store.jsnew file mode 100644index 000000000..dfe5fa997--- /dev/null+++ b/examples/custom-map-style/src/store.js@@ -0,0 +1,75 @@+// Copyright (c) 2021 Uber Technologies, Inc.+//+// Permission is hereby granted, free of charge, to any person obtaining a copy+// of this software and associated documentation files (the "Software"), to deal+// in the Software without restriction, including without limitation the rights+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+// copies of the Software, and to permit persons to whom the Software is+// furnished to do so, subject to the following conditions:+//+// The above copyright notice and this permission notice shall be included in+// all copies or substantial portions of the Software.+//+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+// THE SOFTWARE.++import {createStore, combineReducers, applyMiddleware, compose} from 'redux';+import keplerGlReducer from 'kepler.gl/reducers';+import {enhanceReduxMiddleware} from 'kepler.gl/middleware';++const mapStyles = {+ voyager: {+ id: 'voyager',+ label: 'Voyager',+ url: 'https://api.maptiler.com/maps/voyager/style.json?key=ySQ0fIYn7eSl3ppOeEJd',+ icon: 'https://api.maptiler.com/maps/voyager/256/0/0/0.png?key=ySQ0fIYn7eSl3ppOeEJd'+ },+ terrain: {+ id: 'terrain',+ label: 'Outdoor',+ url: 'https://api.maptiler.com/maps/outdoor/style.json?key=ySQ0fIYn7eSl3ppOeEJd',+ icon: 'https://openmaptiles.org/img/styles/terrain.jpg',+ layerGroups: [+ {+ slug: 'label',+ filter: ({id}) => id.match(/(?=(label|place-|poi-))/),+ defaultVisibility: true+ },+ {+ slug: 'road',+ filter: ({id}) => id.match(/(?=(road|railway|tunnel|street|bridge))(?!.*label)/),+ defaultVisibility: true+ },+ {+ slug: 'terrain',+ filter: ({id}) => id.match(/(?=(hillshade))/),+ defaultVisibility: true+ },+ {+ slug: 'building',+ filter: ({id}) => id.match(/building/),+ defaultVisibility: true+ }+ ]+ }+};+const customizedKeplerGlReducer = keplerGlReducer.initialState({+ mapStyle: {+ mapStyles,+ styleType: 'voyager'+ }+});++const reducers = combineReducers({+ keplerGl: customizedKeplerGlReducer+});++const middlewares = enhanceReduxMiddleware([]);+const enhancers = [applyMiddleware(...middlewares)];++export default createStore(reducers, {}, compose(...enhancers));diff --git a/examples/custom-map-style/webpack.config.js b/examples/custom-map-style/webpack.config.jsnew file mode 100644index 000000000..4f583ed0f--- /dev/null+++ b/examples/custom-map-style/webpack.config.js@@ -0,0 +1,64 @@+// Copyright (c) 2021 Uber Technologies, Inc.+//+// Permission is hereby granted, free of charge, to any person obtaining a copy+// of this software and associated documentation files (the "Software"), to deal+// in the Software without restriction, including without limitation the rights+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+// copies of the Software, and to permit persons to whom the Software is+// furnished to do so, subject to the following conditions:+//+// The above copyright notice and this permission notice shall be included in+// all copies or substantial portions of the Software.+//+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+// THE SOFTWARE.++// NOTE: To use this example standalone (e.g. outside of deck.gl repo)+// delete the local development overrides at the bottom of this file++// avoid destructuring for older Node version support+const resolve = require('path').resolve;+const join = require('path').join;+const webpack = require('webpack');++const CONFIG = {+ // bundle app.js and everything it imports, recursively.+ entry: {+ app: resolve('./src/main.js')+ },+ output: {+ path: resolve(__dirname, 'build'),+ filename: 'bundle.js',+ publicPath: '/'+ },++ devtool: 'source-map',++ module: {+ rules: [+ {+ test: /\.js$/,+ loader: 'babel-loader',+ include: join(__dirname, 'src'),+ exclude: [/node_modules/]+ }+ ]+ },++ node: {+ fs: 'empty'+ },++ // Optional: Enables reading mapbox token from environment variable+ plugins: [new webpack.EnvironmentPlugin(['MapboxAccessToken'])]+};++// This line enables bundling against src in this repo rather than installed deck.gl module+module.exports = env => {+ return env ? require('../webpack.config.local')(CONFIG, __dirname)(env) : CONFIG;+};diff --git a/package.json b/package.jsonindex 2838e9c84..886584333 100644--- a/package.json+++ b/package.json@@ -36,6 +36,7 @@"start:custom-reducer": "npm run install-and-start -- examples/custom-reducer start-local","start:replace-component": "npm run install-and-start -- examples/replace-component start-local","start:custom-theme": "npm run install-and-start -- examples/custom-theme start-local",+ "start:custom-map-style": "npm run install-and-start -- examples/custom-map-style start-local","start:node-app": "npm run install-and-start -- examples/node-app start-local","start:web": "npm run install-and-start -- website start","start:https": "npm run install-and-start -- examples/demo-app start-local-https",diff --git a/src/components/modals/add-map-style-modal.js b/src/components/modals/add-map-style-modal.jsindex aa16db700..a8acfe035 100644--- a/src/components/modals/add-map-style-modal.js+++ b/src/components/modals/add-map-style-modal.js@@ -179,6 +179,36 @@ function AddMapStyleModalFactory() {<div className="add-map-style-modal"><StyledModalContent><StyledModalVerticalPanel>+ <StyledModalSection>+ <div className="modal-section-title">+ <FormattedMessage id={'modal.addStyle.pasteTitle'} />+ </div>+ <div className="modal-section-subtitle">+ {intl.formatMessage({id: 'modal.addStyle.pasteSubtitle0'})}+ <InlineLink+ target="_blank"+ href="https://www.mapbox.com/help/studio-manual-publish/#style-url"+ >+ {' '}+ {intl.formatMessage({id: 'modal.addStyle.pasteSubtitle2'})}+ </InlineLink>{' '}+ {intl.formatMessage({id: 'modal.addStyle.pasteSubtitle3'})}+ <InlineLink+ target="_blank"+ href="https://docs.mapbox.com/mapbox-gl-js/style-spec"+ >+ {' '}+ {intl.formatMessage({id: 'modal.addStyle.pasteSubtitle4'})}+ </InlineLink>+ </div>+ <InputLight+ type="text"+ value={inputStyle.url || ''}+ onChange={({target: {value}}) => this.props.inputMapStyle({url: value})}+ placeholder="e.g. mapbox://styles/username/style, http://my.stles.com/xxx/style.json "+ />+ </StyledModalSection>+<StyledModalSection><div className="modal-section-title"><FormattedMessage id={'modal.addStyle.publishTitle'} />@@ -199,6 +229,7 @@ function AddMapStyleModalFactory() {</InlineLink>{' '}{intl.formatMessage({id: 'modal.addStyle.publishSubtitle4'})}</div>+<div className="modal-section-subtitle">{intl.formatMessage({id: 'modal.addStyle.publishSubtitle5'})}<InlineLink@@ -217,27 +248,7 @@ function AddMapStyleModalFactory() {placeholder={intl.formatMessage({id: 'modal.addStyle.exampleToken'})}/></StyledModalSection>- <StyledModalSection>- <div className="modal-section-title">- <FormattedMessage id={'modal.addStyle.pasteTitle'} />- </div>- <div className="modal-section-subtitle">- {intl.formatMessage({id: 'modal.addStyle.pasteSubtitle1'})}- <InlineLink- target="_blank"- href="https://www.mapbox.com/help/studio-manual-publish/#style-url"- >- {' '}- {intl.formatMessage({id: 'modal.addStyle.pasteSubtitle2'})}- </InlineLink>- </div>- <InputLight- type="text"- value={inputStyle.url || ''}- onChange={({target: {value}}) => this.props.inputMapStyle({url: value})}- placeholder="e.g. mapbox://styles/uberdataviz/abcdefghijklmnopq"- />- </StyledModalSection>+<StyledModalSection><div className="modal-section-title"><FormattedMessage id={'modal.addStyle.namingTitle'} />diff --git a/src/components/side-panel/map-manager.js b/src/components/side-panel/map-manager.jsindex c56972dd9..aca98dd0c 100644--- a/src/components/side-panel/map-manager.js+++ b/src/components/side-panel/map-manager.js@@ -26,7 +26,6 @@ import MapStyleSelectorFactory from 'components/side-panel/map-style-panel/map-simport LayerGroupSelectorFactory from 'components/side-panel/map-style-panel/map-layer-selector';import {Add} from 'components/common/icons';-import {DEFAULT_LAYER_GROUPS} from 'constants/default-settings';import ColorSelector from './layer-panel/color-selector';import {createSelector} from 'reselect';import {injectIntl} from 'react-intl';@@ -61,7 +60,8 @@ function MapManagerFactory(MapStyleSelector, LayerGroupSelector) {render() {const {mapStyle, intl} = this.props;- const editableLayers = DEFAULT_LAYER_GROUPS.map(lg => lg.slug);+ const currentStyle = mapStyle.mapStyles[mapStyle.styleType] || {};+ const editableLayers = (currentStyle.layerGroups || []).map(lg => lg.slug);const hasBuildingLayer = mapStyle.visibleLayerGroups['3d building'];const colorSetSelector = createSelector(this.buildingColorSelector,diff --git a/src/localization/ca.js b/src/localization/ca.jsindex eecdfdd0f..c45ac2cf9 100644--- a/src/localization/ca.js+++ b/src/localization/ca.js@@ -274,7 +274,7 @@ export default {warning: "estàs a punt d'esborrar aquest conjunt de dades. Afectarà {length} capes"},addStyle: {- publishTitle: "1. Publica el teu estil a Mapbox o proporciona el token d'accés",+ publishTitle: "2. Publica el teu estil a Mapbox o proporciona el token d'accés",publishSubtitle1: 'Pots crear el teu propi estil de mapa a',publishSubtitle2: 'i',publishSubtitle3: 'publicar',@@ -284,7 +284,7 @@ export default {publishSubtitle7:'aquí. *kepler.gl és una aplicació client, les dades romanen al teu navegador..',exampleToken: 'p.ex. pk.abcdefg.xxxxxx',- pasteTitle: "2. Enganxa la URL de l'estil",+ pasteTitle: "1. Enganxa la URL de l'estil",pasteSubtitle1: 'Què és un',pasteSubtitle2: "URL de l'estil",namingTitle: '3. Posa nom al teu estil'diff --git a/src/localization/en.js b/src/localization/en.jsindex 51245fac3..120294399 100644--- a/src/localization/en.js+++ b/src/localization/en.js@@ -233,7 +233,7 @@ export default {exportImage: 'Export Image',exportData: 'Export Data',exportMap: 'Export Map',- addCustomMapboxStyle: 'Add Custom Mapbox Style',+ addCustomMapboxStyle: 'Add Custom Map Style',saveMap: 'Save Map',shareURL: 'Share URL'},@@ -275,7 +275,8 @@ export default {warning: 'you are going to delete this dataset. It will affect {length} layers'},addStyle: {- publishTitle: '1. Publish your style at mapbox or provide access token',+ publishTitle:+ '2. If entered mapbox stule url in step.1, publish your style at mapbox or provide access token. (Optional)',publishSubtitle1: 'You can create your own map style at',publishSubtitle2: 'and',publishSubtitle3: 'publish',@@ -285,9 +286,12 @@ export default {publishSubtitle7:'here. *kepler.gl is a client-side application, data stays in your browser..',exampleToken: 'e.g. pk.abcdefg.xxxxxx',- pasteTitle: '2. Paste style url',+ pasteTitle: '1. Paste style url',+ pasteSubtitle0: 'Style url can be a mapbox',pasteSubtitle1: 'What is a',pasteSubtitle2: 'style URL',+ pasteSubtitle3: 'or a style.json using the',+ pasteSubtitle4: 'Mapbox GL Style Spec',namingTitle: '3. Name your style'},shareMap: {diff --git a/src/utils/map-style-utils/mapbox-gl-style-editor.js b/src/utils/map-style-utils/mapbox-gl-style-editor.jsindex 98e4fda46..f7962c107 100644--- a/src/utils/map-style-utils/mapbox-gl-style-editor.js+++ b/src/utils/map-style-utils/mapbox-gl-style-editor.js@@ -191,10 +191,10 @@ export function scaleMapStyleByResolution(mapboxStyle, scale) {* @return {Object} mergedLayerGroups*/export function mergeLayerGroupVisibility(defaultLayerGroup, currentLayerGroup) {- return Object.keys(currentLayerGroup).reduce(+ return Object.keys(defaultLayerGroup).reduce((accu, key) => ({...accu,- ...(defaultLayerGroup.hasOwnProperty(key) ? {[key]: currentLayerGroup[key]} : {})+ ...(currentLayerGroup.hasOwnProperty(key) ? {[key]: currentLayerGroup[key]} : {})}),defaultLayerGroup);