dimfeld / svelte-maplibre

Svelte bindings for the MapLibre mapping library
https://svelte-maplibre.vercel.app
MIT License
344 stars 40 forks source link

Defer updating Layer’s layout and paint properties until Map style is fully loaded #204

Closed ciscorn closed 1 month ago

ciscorn commented 1 month ago

When both the MapLibre's style and Layer properties are modified almost simultaneously, the following error occurs:

style.ts:556 Uncaught (in promise) Error: Style is not done loading.
    at de._checkLoaded (style.ts:556:19)
    at de.setLayoutProperty (style.ts:1148:14)
    at t.Map.setLayoutProperty (map.ts:2603:20)
    at Layer.svelte:221:39
    at compare.js:9:21
    at $$self.$$.update (Layer.svelte:225:5)
    at update (scheduler.js:115:6)
    at flush (scheduler.js:79:5)

This PR modifies the code to check map.style._loaded, and if the style is loading, it delays the setLayoutProperty and setPaintProperty.

image

changeset-bot[bot] commented 1 month ago

⚠️ No Changeset found

Latest commit: 06f63bde77651e101e0f6aceefce62689a22ac2d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

vercel[bot] commented 1 month ago

@ciscorn is attempting to deploy a commit to the Daniel Imfeld's projects Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] commented 1 month ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
svelte-maplibre ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 3, 2024 8:03am
dimfeld commented 1 month ago

Thanks! Published in v0.9.14