-
Notifications
You must be signed in to change notification settings - Fork 409
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
#3533 Add Zoom to Layer Dashboard map widget #4595
Conversation
@offtherailz Can you look at this PR and comment about the issue we talked in the chat. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
diff --git a/web/client/plugins/widgetbuilder/enhancers/handleMapZoomLayer.js b/web/client/plugins/widgetbuilder/enhancers/handleMapZoomLayer.js
index 85d305c05..a7c8b8dbb 100644
--- a/web/client/plugins/widgetbuilder/enhancers/handleMapZoomLayer.js
+++ b/web/client/plugins/widgetbuilder/enhancers/handleMapZoomLayer.js
@@ -59,7 +59,7 @@ const enhancer = compose(
const currentEPSG = !!head(layersBbox) && uniqueCRS.crs !== 'differentCRS' && uniqueCRS.crs;
return currentEPSG && Proj4js.defs(currentEPSG);
},
- zoomTo: ({ editorData = {}, onEditWidget = () => {} }) => (selectedNodes) => {
+ zoomTo: ({ editorData = {}, setMap = () => {} }) => (selectedNodes) => {
const map = editorData.map;
const layers = editorData.map.layers;
const selectedLayers = selectedNodes.map(nodeId => layers.find(layer => layer.id === nodeId));
@@ -93,16 +93,13 @@ const enhancer = compose(
let newBounds = { minx: bounds[0], miny: bounds[1], maxx: bounds[2], maxy: bounds[3] };
let newBbox = { ...map.bbox, bounds: newBounds };
- const newEditorData = {
- ...editorData,
- map: {
- ...editorData.map,
- center,
- zoom,
- bbox: newBbox
- }
- };
- onEditWidget(newEditorData);
+ setMap({
+ ...editorData.map,
+ center,
+ zoom,
+ bbox: newBbox,
+ mapStateSource: "tool"
+ });
}
}
}),
diff --git a/web/client/plugins/widgetbuilder/enhancers/manageLayers.js b/web/client/plugins/widgetbuilder/enhancers/manageLayers.js
index 8e4c5ddd1..00f932252 100644
--- a/web/client/plugins/widgetbuilder/enhancers/manageLayers.js
+++ b/web/client/plugins/widgetbuilder/enhancers/manageLayers.js
@@ -19,7 +19,8 @@ module.exports = compose(
layers: editorData.map && editorData.map.layers
})),
connect(() => ({}), {
- setLayers: layers => onEditorChange('map.layers', layers)
+ setLayers: layers => onEditorChange('map.layers', layers),
+ setMap: map => onEditorChange('map', map)
}),
withHandlers({
addLayer: ({ layers = [], setLayers = () => { } }) => layer => setLayers([...layers, normalizeLayer(layer)]),
This was my suggested draft fix, please
- move connect for setMap in the proper enancher.
- unserstand,
- try all use cases
- add unit tests
@offtherailz I have discovered that my fix doesn't work smoothly because of the changes introduced by this PR #4278. I have tried to apply it to codebase before that PR and everything is working fine. That PR seems to introduce many things and not easy for me to understand all changes it made but I will work with the PR author, in this case @MV88 to identify the problem. Before that PR all actions we saw yesterday are called in the same order but with different effect compared to if I call them after that PR. I have created this #4611 working PR to demonstrate my point |
51aeaee
to
a7fe66e
Compare
Here's what i have found based on my investigation. The fix for Issue #4614 is just to remove this line, but i'm not sure it causes regression in geostory, still need to verify it. this pr does not work with that fix, the state is updated correctly (i tested the version without last commit "replace editWidget with onEditorChange") but then because of this if condition, the map position in preview does not update. I repeat i'm not sure this PR will work after fixing #4614 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is ok...
Anyway Until #4614 testing this becomes hard. I tested with this dashboard and it works.
http://localhost:8081/#/dashboard/5593
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just merge my fix on #4614 before this
@MV88, please provide a backport PR to 2019.03.xx |
* Add Zoom to Layer Dashboard map widget * replace editWidget with onEditorChange
Description
Add Zoom to Layer tool in Dashboard map widget
This PR is blocked by some regression introduced by #4278.
Issues
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (check one with "x", remove the others)
What is the current behavior? (You can also link to an open issue here)
see #3533
What is the new behavior?
Zoom to layer tool added
Does this PR introduce a breaking change? (check one with "x", remove the other)
If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...
Other information: