Skip to content

Conversation

@katemihalikova
Copy link

RD-888

Objective

Refactor the whole component into standalone component without svelte dependency

Description

Svelte has been removed, geocoder has been rewritten into Lit.js, it is now usable standalone, separate classes for MapLibre GL and MapTiler SDK were created, WIP

Acceptance

Manual testing in demos, WIP

@katemihalikova katemihalikova requested a review from lesbaa November 1, 2025 02:00
@katemihalikova katemihalikova self-assigned this Nov 1, 2025
@katemihalikova katemihalikova changed the base branch from main to next November 1, 2025 02:00
Copy link
Contributor

@lesbaa lesbaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All in, I like the look of Lit. But I'm guessing it's all still in progress?

I'm not a big fan of the label / goto code and I think there's definitely some places where the logic could do with some refactoring / simplifying if at all possible (I'm thinking those nested if / else if / else statements)

I'd love for us to get rid of as many of the headaches as possible from the previous implementation.

Also some form of testing (even if it's just the base use cases) would be good and the readme etc.


this.#setAndSaveData(undefined);

block: if (picked) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is probably lifted from the original geocoding control, but with the labels / gotos like this I feel it's difficult to read the code and they're generally considered bad juju. Maybe some of the logic could be inverted?

if (geoms.length > 0) {
  const unioned = union(...);
  if (unioned) { // instead of !unioned
    setMask(...);
    handled = true;
  }
}

Would it be difficult to refactor ahead of release?

break ok;
}

setMask(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this setMask function (which I know comes from the original geocoding control) being deliberately "not pure" is problematic for me. I think having that as a pure function that returns the mask (or null) would maybe be cleaner and more intuitive rather than passing a callback.

}

if (handled) {
// nothing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, feels like the logic could be inverted and then the method could return early?

type: "geojson",
data: this.#savedData,
});
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would if (!source && !this.#savedData) return; work better?

}
>;

// NOTE We can't use Maplibre `Event` - see https://github.com/maplibre/maplibre-gl-js/issues/5015
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these events and types can all be moved out into a separate file, no?

@@ -0,0 +1,888 @@
import {
Evented,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this just a backup file? Can probably get removed, no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants