Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comparsion to svelte-maplibre #75

Open
MRocholl opened this issue Jan 13, 2025 · 1 comment
Open

Comparsion to svelte-maplibre #75

MRocholl opened this issue Jan 13, 2025 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@MRocholl
Copy link

Hello!
Thank you for contributing another awesome library for maplibre to the svekosystem.
I see that you took inspiration from the existing svelte-maplibre library.
I'm trying to decide with which library to go as of now. I'm curious as to why you started this new project.
Is there some specific pain this library solves better (or differently)?
Thank you for you hard work.
Best

@ciscorn
Copy link
Member

ciscorn commented Jan 14, 2025

Thank you for your important question! Here's a detailed explanation of why we started this project and how we address specific considerations differently:

The primary motivation was to redesign the API with Svelte 5 in mind. While we certainly considered direct collaboration with the developers of svelte-maplibre, it seemed difficult for us, given the disruptive changes required for such a redesign.

Additionally, as active MapLibre users, we have valued staying close to MapLibre's core API and ensuring that its powerful features remain accessible without opinionated abstractions.

1. Avoid introducing unnecessary abstractions (Stay true to MapLibre's API)

  • Other libraries, like visgl/react-maplibre and svelte-maplibre tend to introduce their own abstractions:
    • In visgl/react-maplibre: interactiveLayerIds, and others.
    • In svelte-maplibre: <MarkerLayer>, manageHoverState, hoverCursor, etc.
  • In contrast, our library focuses on making MapLibre’s native concepts declarative and reactive, including:
    • <FeatureState> (Map.setFeatureState)
    • <QuerySourceFeatures> (Map.querySourceFeatures) and <QueryRenderedFeatures> (Map.queryRenderedFeatures)
  • We believe this approach provides the following benefits:
    • Easier knowledge transfer between vanilla MapLibre GL JS and wrapping libraries
    • Simplicity and flexibility
    • Future-proof design

2. Attention to fundamental behaviors

  • Current svelte-maplibre reconstructs all user layers when switching base styles, causing inefficiencies and visual flickering. This library ensures that user styles remain intact when the base style changes.
  • In (bare) MapLibre GL JS, performing style-related actions while other styles are still loading leads to fatal errors. This library ensures that style application is fully complete before performing additional operations.

3. Re-designed with Svelte 5 in mind from the beginning

While svelte-maplibre is also working to adapt to Svelte 5, our library has been designed with Svelte 5 in mind from the very beginning. For example:

  • Thanks to Svelte 5, we can provide comprehensive event handling without excessive event subscriptions to MapLibre's event system.
  • With Svelte 5, we can directly use MapLibre's type definitions to write a cleaner, more maintainable code. This also enables automatic documentation generation. These factors will contribute to the library's long-term sustainability.

@ciscorn ciscorn pinned this issue Jan 14, 2025
@ciscorn ciscorn changed the title Comparsion to svelte-maplibre Comparsion to svelte-maplibre Jan 14, 2025
@ciscorn ciscorn added the documentation Improvements or additions to documentation label Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants