Skip to content

Migrate maps-js samples to the latest API surface - #142

Open
manz wants to merge 16 commits into
masterfrom
maps-js-latest-api
Open

manz wants to merge 16 commits into
masterfrom
maps-js-latest-api

Conversation

@manz

@manz manz commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Brings the maps-js samples in line with the current API: <wmp-map>, AdvancedMarkerElement / PinElement, the InfoWindow object form with a marker passed straight in as the anchor, and moveCamera(). Samples that load other SDKs (localities, multisearch, store-locator widget) are out of scope.

  • The SDK host is configurable, and a sample can opt into the importLibrary loader shim (loaderShim flag), which replaces callback=initMap.
  • setOptions() only moved the camera when the map was built, and every sample works on the existing map through .innerMap, so camera changes silently did nothing. Those calls now use moveCamera(). maps-js #1582 also makes setOptions() move the camera on an existing map, but the samples no longer rely on it.
  • Solid-color markers use PinElement instead of raster images, and labelled ones use glyphText instead of hand-positioned spans.
  • JSX is enabled in the per-sample vite/oxc config, otherwise the react-map-* builds fail.
  • Bumped to @types/woosmap.map 1.4.28, which ships the new API surface. woosmap.map.data.Feature is now woosmap.map.Data.Feature.
  • The loader shim passes the sample's libraries and language to the script URL. widgets is not an importLibrary() name, so the indoor widget samples never loaded their bundle.
  • Lint is clean and runs in CI. The config still disabled the pre-v8 typescript-eslint rule names, so those overrides were ignored. Most sample fixes swap any for the real types from 1.4.28.

dist/ is left to the release bot.

The loader shim is opt-in per sample (loaderShim flag): it replaces
callback=initMap rather than extending it.
InfoWindow object form, moveCamera, AdvancedMarkerElement, <wmp-map>,
and the importLibrary preload shim. Localities/multisearch/store-locator
widget samples load separate SDKs, out of scope.
Rolldown-vite's oxc transform needs jsx explicitly enabled; without it
every .tsx app build (react-map-*) fails.
maps-js PR #1580 lets InfoWindow.open() take an AdvancedMarkerElement
anchor directly. Drops the position-snapshot workaround.
AdvancedMarkerElement content attached via map:/setMap() lands in the
map's marker pane inside wmp-map's shadow root, not light DOM. Slotting
only applies to markers declared as wmp-map children in markup.
maps-js's AdvancedMarkerElement content now stays in light DOM even for
programmatic markers on a shadow-rooted map, so style.scss's .popover
rules reach it directly again.
setOptions() only moves the camera at construction; on the already-built
map every sample grabs via .innerMap, it silently did nothing.
Flat teardrop icons render natively; labeled markers drop their manual
span-positioning code for glyphText.
@wgsadmin wgsadmin added the ai-reviewer-queued Nairi reviewer has a review in flight for this PR label Oct 20, 2026

@wgsadmin wgsadmin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Found three issues in the migration.

  • Blocker: The Test workflow fails because the checked-in type dependency does not expose the API used throughout this PR. Representative output: samples/add-map/index.ts(6,21): error TS2339: Property 'importLibrary' does not exist on type 'typeof map'. The same run reports 280 errors covering MapElement, moveCamera, marker, and the new InfoWindow.open form.
  • Blocker: The loader no longer requests the widgets bundle, and e2e fails both indoor widget samples with TypeError: woosmap.map.IndoorWidget is not a constructor. The navigation widget has the same latent load path.
  • Should fix: The external-layer style selector constructs a second map using <wmp-map> itself as the container instead of updating the component's existing innerMap.

The failing workflows are Test (run 39387030521) and e2e (run 39387030574).

Comment thread samples/add-map/index.ts

function initMap(): void {
async function initMap(): Promise<void> {
await woosmap.map.importLibrary("maps");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Blocker: This first new API call illustrates the repo-wide type-check failure: the current @types/woosmap.map declarations do not include importLibrary, MapElement, moveCamera, the marker namespace, or the object-form InfoWindow.open. The Test workflow stops with 280 TypeScript errors, so every migrated sample currently fails the required compile check. Please make matching declarations available to tsc (for example, update/pin a released types package or add the necessary local declarations) and refresh the lockfile.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 97a7d80: bumped to @types/woosmap.map 1.4.28, which ships importLibrary, MapElement, moveCamera, the marker namespace and the object-form InfoWindow.open. test passes now.

Comment thread src/_includes/layout.njk Outdated
maps[L] = (name, ...args) =>
libs.add(name) && load().then(() => maps[L](name, ...args));
}
})({ key: "{{ WOOSMAP_PUBLIC_API_KEY }}" });

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Blocker: The shim drops the sample's existing libraries value. The three indoor widget configs still declare libraries: "widgets", but this loader is invoked with only the key and those samples request only importLibrary("maps"); widgets is not an accepted importLibrary library, so its bundle is never fetched. The e2e job confirms this with woosmap.map.IndoorWidget is not a constructor for both widget samples, and indoor-navigation-widget will reach the same missing bundle later. Please seed/merge the configured libraries into the loader URL, or keep these widget samples on the classic loader path.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in e1f40da: the shim now starts from the sample's configured libraries (and forwards language), so the widget samples request libraries=widgets,maps and IndoorWidget is defined.

Comment thread samples/map-external-layer/index.ts Outdated
function applyStyle(name: string) {
const styles = STYLE_PRESETS[name] ?? [];
map = new window.woosmap.map.Map(
map = new woosmap.map.Map(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should fix: #map is now a <wmp-map>, which already owns its map in a shadow-root container. Constructing another Map on the custom element when the style changes leaves MapElement.innerMap pointing at the original instance and inserts the second renderer into the host's light-DOM/slot structure; the style dropdown can therefore produce an overlaid, non-interactive map rather than replacing the displayed one. Please reuse the innerMap and apply the new styles with map.setOptions(...) instead of constructing a second map.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 9cff871: the style switch now calls innerMap.setOptions({styles}). The layer is still reapplied afterwards since restyling reloads the base style.

@wgsadmin wgsadmin added ai-reviewer-done Nairi reviewer has finished with this PR \u2014 remove to ask again and removed ai-reviewer-queued Nairi reviewer has a review in flight for this PR labels Oct 20, 2026
manz added 3 commits October 20, 2026 13:04
Feature moved from woosmap.map.data to woosmap.map.Data in the types.
widgets is not an importLibrary() name, so the indoor widget samples never fetched their bundle.
@manz manz removed the ai-reviewer-done Nairi reviewer has finished with this PR \u2014 remove to ask again label Oct 20, 2026
manz added 2 commits October 20, 2026 13:51
Mostly any -> real types now that @types/woosmap.map 1.4.28 covers the API.
@wgsadmin wgsadmin added the ai-reviewer-queued Nairi reviewer has a review in flight for this PR label Oct 20, 2026

@wgsadmin wgsadmin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed the latest head against master. The earlier typings, widget-preload, and external-layer issues are addressed.

  • Should fix: the three React loaders bypass the new configurable SDK host.
  • Consider: two store samples still depend on setOptions() applying camera fields to an existing innerMap.

A focused tsc --noEmit --skipLibCheck check passes. GitHub’s latest Test and e2e workflow runs were skipped (the triggering review was a COMMENT), so runtime e2e coverage has not been refreshed for this head.

Comment thread samples/react-map-basic/index.tsx Outdated
params.set("libraries", [...libs].join(","));
for (const k in g) params.set(k, g[k]);
params.set("callback", "woosmap.map." + CB);
s.src = "https://sdk.woosmap.com/map/map.js?" + params;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

⚠️ WOOSMAP_SDK_HOST does not reach this loader: all three React samples still hard-code production here. A site built with the new host override will therefore exercise production for these samples (and can fail when testing an API not yet on prod), while every layout-driven sample uses the configured host. Could we pass the generated host into installLoaderShim (for example through VITE_WOOSMAP_SDK_HOST) and apply the same change in the other two React samples?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in a8724d8: the build now emits VITE_WOOSMAP_SDK_HOST and the your-api-key transform swaps the hard-coded host in all three React samples.

await woosmap.map.importLibrary("marker");

map = (document.getElementById("map") as woosmap.map.MapElement).innerMap;
map.setOptions(mapOptions);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🟡 mapOptions still includes center and zoom, so this line depends on maps-js #1582 to move the existing innerMap camera—the behavior the rest of this PR explicitly avoids. With a configurable host serving a MapElement-capable build from before #1582, this sample stays at the component defaults; stores-search has the same remaining call. Could we pass only non-camera options to setOptions() and call moveCamera() with the camera fields in both samples?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 8578f38: center/zoom dropped from mapOptions; both stores-list-sync-map and stores-search now set the camera with moveCamera().

@wgsadmin wgsadmin added ai-reviewer-done Nairi reviewer has finished with this PR \u2014 remove to ask again and removed ai-reviewer-queued Nairi reviewer has a review in flight for this PR labels Oct 20, 2026
@manz manz self-assigned this Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-reviewer-done Nairi reviewer has finished with this PR \u2014 remove to ask again

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants