Repository navigation
Conversation
Apply tile-proxy compatible setLayerProperties transforms to the style document in the browser, and document the layer's options.
Type transforms as JSON so they fit layer options, reject malformed styleTransforms containers, cancel pending style loads on disposal (also for the untransformed path), share pending style requests per URL and document the stricter browser contract.
🦋 Changeset detectedLatest commit: 18f775b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hosts that want a variant of a vector basemap style (other colours, hidden layers, an emphasis) currently need a server that rewrites the style document. This lets a host apply the same kind of rewrite in the browser.
MapboxVectorLayeraccepts an initial-onlystyleTransformsoption: a list ofsetLayerPropertiestransforms in the format the tile-proxy uses, applied to the style document before it reachesol-mapbox-style. Without the option the load path is unchanged.styleUrlitself (http(s) or relative only) and passes the transformed object on together with the originalstyleUrl, so relative source and sprite URLs still resolve against it. Layers that share one style URL share one pending request, and each transforms its own copy.applyMapboxStyleTransformsis exported as a pure function with JSON-compatible types, so a transform list is assignable to typed layeroptions.setLayerPropertiesand plain JSON and is stricter than the proxy: malformed containers and invalid transforms surface as a style load error before any request is made.styleUrlorstyleTransformsin the state recreates the layer, as for other initial-only options.MapboxVectorLayernow cancels its own pending style request and no longer applies a style, changes source state or gets a source re-attached when a load finishes late. The re-attachment race also existed for layers without transforms.docs/integration/TILE_PROXY.mddocuments the option, the contract and its differences from the proxy, and for the first time lists the layer's existing options (sourceId,layers,background,accessToken,declutter), how to register the definition and theol-mapbox-stylepeer dependency.Limitations: with transforms,
mapbox://style URLs are not supported. On the untransformed path the requests made byol-mapbox-styleitself cannot be aborted on disposal; they no longer affect the disposed layer.Test plan
pnpm --filter @mapsight/core test(352 tests),typecheck(includes a compile-time check that transforms fit layer options),lint(no errors),pnpm run checkstyleTransformsorstyleUrlrecreates the layer, equal options keep itol-mapbox-stylewith a stubbedfetch: relative source URL resolution and the source re-attachment race