Comments (4)
@gingerizer
The current behavior is intended. To make the config small and only include the neccessary part, mapStyle
config will not include the default set of map styles, because they are constants that can be loaded later in the application. when exporting conifg, mapStyles will only contain the ones added by the user.
Is there a reason you want all the map styles to be saved in the config?
from kepler.gl.
My base configuration is such that I am not using any of the default map styles that are pre-configured as constants. Ideally I would be able to disable the use of these default maps (and the subsequent calls made to retrieve the styles) since I have configured my own. I'm working in an offline environment.
<KeplerGl
mapboxApiAccessToken=""
id="keplerMap"
width={width}
height={height}
mapStyles={CUSTOM_MAP_STYLES}
/>
Since I have my own map styles configured as a custom set of default styles when I add new data to the map I have to re-set the map styles in the config. I was hoping that getMapConfig()
would provide this set for me.
Sure I can add all of the default styles back to the config, however the user might have added their own custom styles that weren't in the default configuration and because I've updated the map with new data those changes would be lost- would they not?
If they aren't included in the config to keep it small then is there a way to access them for those that need it? Also, does that mean that mapStyles
will always be empty? If so why bother including it in the config response?
from kepler.gl.
I've discovered a way to easily get the mapStyles. The method shown in visacademy is as such:
// This method is used as reference to show how to export the current kepler.gl instance configuration
// Once exported the configuration can be imported using parseSavedConfig or load method from KeplerGlSchema
getMapConfig() {
// retrieve kepler.gl store
const {keplerGl} = this.props;
// retrieve current kepler.gl instance store
const {map} = keplerGl;
// create the config object
return KeplerGlSchema.getConfigToSave(map);
}
Essentially, the map object contains the desired mapStyles which need to be appended to what is returned from the getConfigToSave(map)
which becomes:
// This method is used as reference to show how to export the current kepler.gl instance configuration
// Once exported the configuration can be imported using parseSavedConfig or load method from KeplerGlSchema
getMapConfig() {
// retrieve kepler.gl store
const {keplerGl} = this.props;
// retrieve current kepler.gl instance store
const {map} = keplerGl;
// create the config object
// return KeplerGlSchema.getConfigToSave(map); // does not include any custom configured map styles
let mapConfig = KeplerGlSchema.getConfigToSave(map);
mapConfig.config.mapStyle = map.mapStyle; // Add back the available map styles to the map config
return mapConfig;
}
from kepler.gl.
@gingerizer instead of passing mapStyles in as props at the component level, you can try configure the mapStyle
reducer's inisitalState
by calling keplerGlReducer.intialState()
and pass in your set of mapStyles. You can take a look at this example
All you need to do is
const withUberMapStyles = keplerGlReducer.initialState({
mapStyle: {
// add your own map styles as default to mapStyle reducer
// mapStyles needs to be an object with `id` as the key
mapStyles: DEFAULT_MAP_STYLES.reduce((accu, curr) => ({
...accu,
[curr.id]: curr
}), {})
}
})
from kepler.gl.
Related Issues (20)
- [Bug] Trips Layer not displaying animated data nor time slider HOT 1
- Tooltip not Working When Exporting Map HTML [Bug] HOT 4
- [Bug] module.exports = require('./dist/reducers') HOT 2
- Custom Map Style not working HOT 2
- Tooltip not Working at HTML Map HTM HOT 8
- [Bug]Examples Run Error: "ERROR in ./node_modules/@loaders.gl/gis/node_modules/@math.gl/core/dist/index.js 13:9" HOT 1
- Missing Trip layer. HOT 1
- [Bug]Attempted import error: 'isTable' is not exported from '@loaders.gl/schema' (imported as 'isTable')
- [Bug][Jupyter Widget] Security vulnerabilities in Ipywidgets
- [Bug] HOT 1
- [Bug] issue with demo website on version 3 HOT 7
- [Bug] SSL Cert Expired? HOT 2
- [Bug] Uncaught TypeError: class constructors must be invoked with 'new'
- Is there any way to get coordinates of grid or hexbin HOT 1
- Do we support dashed line (dotted line) in the layers which named "type": "line", HOT 1
- [Bug] injectComponents does not work correctly
- [Bug] Custom Map Style loading failure HOT 8
- change prefix export data csv file name HOT 1
- [Feature Request] Add a compass and a scale HOT 1
- Auto start trip layer animation? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kepler.gl.