fix: use dragging.enable/disable instead of non-existent setDraggable
Leaflet Marker has no setDraggable method. Toggling dragging at runtime requires marker.dragging.enable() / .disable(). Adds a special case for the 'draggable' attribute in the attributeChangedCallback before the generic setter lookup.
This commit is contained in:
parent
be84e61ad0
commit
3846cad38e
@ -52,14 +52,15 @@ export class LeafletMarker extends withProps(HTMLElement, PROPS) {
|
||||
if (!this.#obj || this.#syncing) return;
|
||||
if (name === 'lat' || name === 'lng') {
|
||||
this.#obj.setLatLng([this.#num('lat'), this.#num('lng')]);
|
||||
} else if (name === 'draggable') {
|
||||
if (val !== null) this.#obj.dragging?.enable();
|
||||
else this.#obj.dragging?.disable();
|
||||
} else {
|
||||
const propName = PROP_BY_ATTR.get(name);
|
||||
if (!propName) return;
|
||||
const setter = `set${propName.charAt(0).toUpperCase()}${propName.slice(1)}` as keyof Marker;
|
||||
if (typeof this.#obj[setter] === 'function') {
|
||||
const spec = PROPS[propName as keyof typeof PROPS];
|
||||
const value = spec.kind === 'bool-on' ? val !== null : parseAttributeValue(val);
|
||||
(this.#obj[setter] as (v: unknown) => void)(value);
|
||||
(this.#obj[setter] as (v: unknown) => void)(parseAttributeValue(val));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user