Structuring MapLibre with Svelte 5 and Custom Map functions #286
-
|
Hi! I'm currently using maplibre.svelte in my PWA built with Svelte 5. Since I need to develop custom functions that interact with the map instance—and given my limited software engineering background—I’ve been “vibe coding” a bit (sorry 😅). Despite that, I’ve ended up with a working structure that looks like this: Component HierarchyMapWrapper.svelteMapManager (map.svelte.ts)How can I write custom functions that use the MapLibre map instance without having to create a dedicated class like I’m looking for simpler or more idiomatic ways to interact with the map directly—ideally something that improves both code readability and execution efficiency. Any tips or best practices for structuring this kind of logic in Svelte 5 would be greatly appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
I think the simplest way is to use |
Beta Was this translation helpful? Give feedback.
I think the simplest way is to use
bind:mapon the MapLibre component, and then you can interact with the map. Thesrc/routes/examples/geojson_polygon/+page.sveltefile in this repo is one example of doing that.