Add declarative map swipe (layer compare) feature#1603
Conversation
…ration Co-authored-by: jumpinjackie <563860+jumpinjackie@users.noreply.github.com>
…review feedback Co-authored-by: jumpinjackie <563860+jumpinjackie@users.noreply.github.com>
|
@copilot For an easy demo of this feature, pls add a variant of the existing appdef at |
…ital cities and natural landmarks Co-authored-by: jumpinjackie <563860+jumpinjackie@users.noreply.github.com>
Added The demo appdef sets up a swipe pair on the Australia map with two distinct GeoJSON inline layers:
Both maps use OpenStreetMap as the basemap. The Map Swipe button appears first in the Toolbar and FileMenu containers. Clicking it toggles the swipe slider, which lets you drag to reveal one layer set vs the other side-by-side. To try it out: load the generic viewer with |
|
@copilot I have updated the generic layout template to include a toolbar button for layer swipe command. Invoking the command brings up the layer swipe mode, but I have noticed a few issues.
|
…useIsMapSwipeActive hook Co-authored-by: jumpinjackie <563860+jumpinjackie@users.noreply.github.com>
Fixed in commit Issue 1 & 3 — Swipe shows wrong/missing layers:
Issue 4 — Swipe control monopolizes mouse input: Issue 5 — Public hook for swipe active state: Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot You have a TS build error. Pls fix. |
Co-authored-by: jumpinjackie <563860+jumpinjackie@users.noreply.github.com>
... Fixed in commit |
|
@copilot It's kind of almost there. The only issues I see remaining are:
|
…e command for secondary map Co-authored-by: jumpinjackie <563860+jumpinjackie@users.noreply.github.com>
Fixed in commit 1 — Stale closure in 2 — Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot Still is not happening. Can you add tests cases that lay down your expectations on the expected states of maps and layers in swipe mode? |
Co-authored-by: jumpinjackie <563860+jumpinjackie@users.noreply.github.com>
Added 14 unit tests in
Primary-to-secondary transfer (the "add layer to secondary" scenario):
All 14 tests pass. These tests confirm the |
|
@copilot Now can you extend the tests to also cover the React components representing the layer manager and see if the current expectations still hold? |
… mode Co-authored-by: jumpinjackie <563860+jumpinjackie@users.noreply.github.com>
Done in commit
No-swipe scenario:
Swipe-active scenario:
Parameterized All 646 tests in the suite pass. |
|
@copilot Additional findings from a fresh start, doing these steps first. Hopefully should give you more context to find the underlying issue.
Case 1
Expect: Layer is visually on the left (primary) map only and is visible in the manage layers tab
Expect: Layer is visually on the right (secondary) map only and is visible in the manage layers tab Case 2
Expect: Layer is visually on the right (secondary) map only and is visible in the manage layers tab
Expect: Layer is visually on the left (primary) map only and is visible in the manage layers tab |
…nsferLayerToSwipeSecondary from add flow Co-authored-by: jumpinjackie <563860+jumpinjackie@users.noreply.github.com>
Fixed in commit Root cause:
Fix:
All 647 tests pass. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot I can get added layers to show on both primary and secondary maps if I do the following:
After doing this, the added layers are visible on their respective maps. So whatever internal state the maps are in at step 9 is different from the internal state the maps are in after step 13. Whatever steps 10, 11, 12, 13 are doing, it looks like step 8 should be doing some/all of. |
Co-authored-by: jumpinjackie <563860+jumpinjackie@users.noreply.github.com>
Fixed in commit Bug 1 — z-order (Case 2, step 2 invisible layer): Fix: Bug 2 — apply() name collision (Case 1 "layer already exists" / Case 2 step 3 appearing on both sides): Fix: Filter now uses object identity: A new test in Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Co-authored-by: jumpinjackie <563860+jumpinjackie@users.noreply.github.com>



viewer/data/appdef.split.jsondemo (withSwipePrimaryLabel/SwipeSecondaryLabeldemo labels: "Capital Cities" and "Natural Landmarks")useIsMapSwipeActive()public hooktest/components/map-providers/context.spec.tsxactivateMapSwipelazy-init override from deadgeneric.ts_to the actualMapGuideMapProviderContextinmapguide.tsMapSwipecommandenabledto primary-map-only"Duplicate item added to a unique collection"OL error when switching maps while swipe is active: auto-deactivate swipe (and dispatchsetMapSwipeMode(false)) insetProviderStatebefore the detach/attach map switchanytypes inIReduxStoreRefwith properly typedReadonly<IApplicationState>(viaReduxStore) andReduxDispatchuseActiveSwipePair→useMapSwipeInfo: returnsIMapSwipeInfo | undefined, bundling thepair(IMapSwipePair) and anisSwipePrimaryflag together so callers no longer need to compute primary-map membership separatelyprimaryLabel/secondaryLabelfields toIMapSwipePair, read fromSwipePrimaryLabel/SwipeSecondaryLabelMapGroup extension properties in the appdef (defaults to i18n strings "Primary" / "Secondary")getSwipeableLayers()toMgLayerSetGroupBase(returns both base map layers and_customLayers);activateMapSwipenow uses this for both primary and secondary maps so layers added at runtime after initial load are correctly clipped and showngetEffectiveMapNameAtPixel(pixelX)tobase.tswhich checks if swipe is active and returns the secondary map name when the click pixel is past the swipe divider, ensuring feature selection and other mouse events target the correct map sidetest/api/layer-set-group-swipe.spec.ts— 14 unit tests forMgLayerSetGroupBaseswipe mechanics:getSwipeableLayers(),transferLayerOut/In,apply()isolation, and end-to-end primary-to-secondary layer transfer scenariotest/containers/add-manage-layers.spec.tsx— React component tests forAddManageLayersContainerin swipe mode, covering: dropdown visibility/placement, map selection, blank-screen prevention when secondary unvisited, correctonLayerAddeddispatch target, andrefreshSwipeClips()/transferLayerToSwipeSecondary()call expectationsOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.