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

@MRocholl
Thank you for the important question! Here's a detailed explanation of why we started this project and how it addresses specific considerations differently:

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

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 svelte-maplibre and visgl/react-maplibre, introduce their own abstractions:
    • In svelte-maplibre: <MarkerLayer>, manageHoverState, hoverCursor, etc.
    • In visgl/react-maplibre: interactiveLayerIds, and others.
  • In contrast, this library makes MapLibre’s native concepts declarative and reactive, including:
    • <FeatureState> (Map.setFeatureState)
    • <QuerySourceFeatures> (Map.querySourceFeatures)
    • <QueryRenderedFeatures> (Map.queryRenderedFeatures)
  • We believe this approach ensures:
    • Simplicity and flexibility
    • Easier knowledge transfer between MapLibre GL JS and this library.
    • A future-proof design

2. Attention to Fundamental Behaviors

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

3. Re-designed with Svelte 5 in Mind from the Beginning

While svelte-maplibre is also working to adapt to Svelte 5, this 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 build a cleaner, more maintainable implementation. This also enables automatic documentation generation. These 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