Skip to content

feat: AddTempLayer plugin (WMS/WMTS/XYZ/GeoJSON) + core layer-add bus#126

Open
BhattaraiSijan wants to merge 20 commits into
developmentfrom
feat/add-temp-layer-plugin
Open

feat: AddTempLayer plugin (WMS/WMTS/XYZ/GeoJSON) + core layer-add bus#126
BhattaraiSijan wants to merge 20 commits into
developmentfrom
feat/add-temp-layer-plugin

Conversation

@BhattaraiSijan

@BhattaraiSijan BhattaraiSijan commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Purpose

Add an AddTempLayer plugin — "Add layer from URL" — letting users drop an external WMS / WMTS / XYZ / GeoJSON layer onto the map for the current session, plus the core event-bus and rendering support it needs. Built to the monorepo tool pattern: a portable lib/ of presentational React components with all MMGIS coupling isolated in adapters/, communicating with the core over the window.mmgisAPI event bus only.

Note on discoverability

The plugin shipping without its own trigger button is intentional, not an
oversight. AddTempLayer follows the framework's decoupled-plugin model: it
exposes a bus contract and leaves when and from where it opens to the app
builder.

  • Public contract: emitting addTempLayer:show on the MMGIS bus
    (window.mmgisAPI.emit('addTempLayer:show')) opens the form. Any plugin,
    toolbar button, or host-app code can be the trigger — the plugin does not
    care who emits it.

Proposed Changes

  • [ADD] AddTempLayer plugin (monorepo pattern):
    • lib/ (portable): AddTempLayerPanel (trigger + form state) and AddLayerModal (presentational), utils/url (validateUrl, detectLayerType), utils/icons, BEM blocks-* classes, Path A --theme-* styling.
    • adapters/buildLayerObj (URL → MMGIS layer object), MMGISAddTempLayerAdapter (bus bridge), thin AddTempLayerTool (createRoot), config.json with modern-layout metadata.
  • [ADD] Core bus channels layers:addLayer / layers:removeLayer (Layers_.js), backed by mmgisAPI.addLayer/removeLayer — session-only, in-memory add via resetConfig + modifyLayer (lost on reload).
  • [ADD] WMS / WMTS rendering support:
    • DeckGL: WMSLayer branch in DeckGLHelpers (with parseWmsUrl) selected when tileformat === 'wms'; tileformat threaded through TileLayerOptions and the deck tile call in Map_.js.
    • Leaflet: WMS already supported via WMSColorFilter.
    • WMTS-KVP is rewritten plugin-side into a {z}/{y}/{x} template so it renders through the standard template-tile path in both engines.
  • [CHANGE] layers:listChanged event replaces the direct LayersTool destroy/make on layer mutation, so any subscriber (modern or classic layout) can react — decoupled.
  • [CHANGE] validateUrl rejects internal whitespace, guarding against two URLs pasted into one field.

Issues

Testing

  • npm run typecheck0 errors.

  • Browser (DeckGL engine), verified end-to-end per type — add one URL at a time:

    XYZ

    https://tile.openstreetmap.org/{z}/{x}/{y}.png
    

    WMS (needs a LAYERS param)

    https://ows.terrestris.de/osm/service?SERVICE=WMS&REQUEST=GetMap&LAYERS=OSM-WMS
    

    WMTS — REST template

    https://gibs.earthdata.nasa.gov/wmts/epsg3857/best/BlueMarble_ShadedRelief/default/GoogleMapsCompatible_Level8/{z}/{y}/{x}.jpeg
    

    WMTS — KVP (exercises the KVP→template rewrite)

    https://gibs.earthdata.nasa.gov/wmts/epsg3857/best/wmts.cgi?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=BlueMarble_ShadedRelief&STYLE=default&TILEMATRIXSET=GoogleMapsCompatible_Level8&FORMAT=image/jpeg
    

    GeoJSON (CORS-enabled host)

    https://raw.githubusercontent.com/PublicaMundi/MappingAPI/master/data/geojson/countries.geojson
    

@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown

✅ Version Already Updated

This PR includes a manual version update to 4.2.19-20260721

No automatic version bump needed.

@BhattaraiSijan

Copy link
Copy Markdown
Collaborator Author

Update — URL handling reworked (b8e735cd, 292931f3)

The plugin is now a pure pass-through — it no longer constructs, rewrites, or substitutes anything in the URL. This supersedes the
"WMTS-KVP rewritten into a {z}/{y}/{x} template" point above.

  • Removed buildWmtsTemplate and the {s} substitution; wms/wmts/xyz URLs are passed through verbatim.
  • Two-stage handling in utils/url: detectLayerType (GeoJSON/WMS/WMTS/XYZ, else unsupported) → new validateForType
    structural check (WMS needs LAYERS; XYZ/WMTS need {z}/{x}/{y}; GeoJSON none), with a per-type example URL in the error message.
  • Panel wired to that pipeline; modal help text reworded and error text wraps.
  • Added tests/unit/addTempLayerUrl.spec.js covering detection, validation, and verbatim build (npm run test:unit).

@slesaad slesaad linked an issue Jul 15, 2026 that may be closed by this pull request
@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown

🤖 Version Auto-Bumped

The version has been automatically incremented to 4.2.20-20260722

This commit was added to your PR branch. When you merge this PR, the new version will be included.


If you want a different version, update package.json manually and push to this PR.

BhattaraiSijan and others added 7 commits July 21, 2026 16:34
The plugin is now only the 'Add layer from URL' form, living hidden in a
float-top-right panel. Any plugin reveals it by emitting 'addTempLayer:show';
the close button hides it again. The dotted trigger button is gone — it
belongs to whichever host wants to offer it (e.g. LayerManager).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
parseWmsUrl previously kept only LAYERS
@BhattaraiSijan

Copy link
Copy Markdown
Collaborator Author

Summary of fixes

  • The layer panel in the classic layout stopped refreshing when layers were added or removed at runtime. Restored the direct panel rebuild so it always shows the current layer list.
  • The local development CORS proxy was accidentally disabled by a leftover flag that could never be turned on. Removed the flag so the proxy works automatically in development again.
  • Pasted WMS URLs lost their extra settings (image format, transparency, styles, API keys) in the 3D-capable engine, so layers could render differently than in 2D. These settings are now passed along with every request.
  • Tile URLs with an {s} placeholder were accepted but then silently rendered nothing. The form now rejects them and asks the user to use a real subdomain instead.
  • The WMS rendering path relies on a third-party component marked experimental. Added a code note so future upgrades know to re-verify it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add external service layer plugin

1 participant