Skip to content

[Enhancemen] Export Map (maplegend and locale) as HTML #1598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

lixun910
Copy link
Collaborator

@lixun910 lixun910 commented Sep 1, 2021

This PR is for the issue #1585 (display map legend on an exported map). There is a workaround for this issue that requires user to update the exported HTML file. However, this seems like a reasonable feature enhancement request for the “Export Map as HTML” feature:

  1. when exporting a map to a HTML file, uiState of mapLegend and map locale should be saved in config.
  2. when loading config via addDataToMapUpdater(), the uiState of mapLegend and map locale should be loaded and used as default.

What's added and changed in this PR:

  1. Add a new uiStateSchema class in src/schemas/ui-state-schema.js

  2. Add above uiStateSchema in reducerSchema in src/schemas/schema-manager.js, so the meta data of locale and mapControls:mapLegend in uiState can be saved and loaded via Schema Manager

  3. Since the mapLegend and locale in uiState can be added in JSON configuration, the addDataToMap action should be updated (src/reducers/combined-updaters.js) so customized mapLegend (on/off) and locale can be loaded as default.

  4. Test case #uiStateSchema -> v1 -> save load uiState in test/node/schemas/ui-state-schema-test.js

  5. Test case #composerStateReducer - addDataToMapUpdater: mapLegend in test/node/reducers/composer-state-test.js

  6. Test case #composerStateReducer - addDataToMapUpdater: locale in test/node/reducers/composer-state-test.js

Example: an exported map with Legend switched ON and locale with Spanish(ES)
Screen Shot 2021-08-31 at 4 08 40 PM

1. when exporting map to a HTML file, uiState of mapLegend and map locale should be saved in config.
2. when loading config via `addDataToMapUpdater()`, the uiState of  mapLegend and map locale should be loaded and used as default.

Signed-off-by: Xun Li <[email protected]>
@@ -170,6 +178,18 @@ export const addDataToMapUpdater = (state, {payload}) => {

pick_('uiState')(apply_(toggleModalUpdater, payload_(null))),

if_(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stead of directly call pick_('uiState') in combined updaters, you should add a receiveMapConfigUpdater to ui-state-updaters, and import it here, call it with

import {receiveMapConfigUpdater as uiStateReceiveMapConfigUpdater} from './map-style-updaters';
...
pick_('mapStyle')(apply_(styleMapConfigUpdater, payload_({config: parsedConfig, options}))),
    
pick_('uiState')(apply_(uiStateReceiveMapConfigUpdater, payload_({config: parsedConfig, options}))),

pick_('uiState')(apply_(uiStateLoadFilesSuccessUpdater, payload_(null))),

we have receiveMapConfigUpdater in each of the sub-reducers, to handle merging config into state. We should follow the pattern with uiState too

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @heshan0131! I added receiveMapConfigUpdater in ui-state-updaters, specifically for 'mapLegend' and 'locale'. Are there any other things I should consider in this function when merging received uistate? Thanks!

@lixun910 lixun910 changed the title Enhancement of "Export Map as HTML" [Enhancemen] Export Map (maplegend and locale) as HTML Sep 14, 2021
Instead of directly call pick_('uiState') in combined updaters, adding `receiveMapConfigUpdater` in ui-state-updaters to merge received uistate (specifically mapLegend and mapLocale) with previous state

Signed-off-by: Xun Li <[email protected]>
…hould be set with mapLegend being displayed by default

Signed-off-by: Xun Li <[email protected]>
@igorDykhta igorDykhta added the to check Old PRs with conflicts that should potentially be merged into Kepler.gl label Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
to check Old PRs with conflicts that should potentially be merged into Kepler.gl
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants