diff --git a/README.md b/README.md index 392e906..a59d11d 100644 --- a/README.md +++ b/README.md @@ -161,13 +161,27 @@ Boolean options that default to `false` are enabled by adding the attribute: ```js const el = document.querySelector('leaflet-map'); -el.map; // L.Map instance (undefined before connected) -el.zoom; // current zoom (reads live from map, falls back to attribute) +el.leafletObject; // L.Map instance (undefined before connected) +el.zoom; // current zoom (reads live from map, falls back to attribute) el.scrollWheelZoom = false; // disable at runtime ``` All `leaflet-map` properties are two-way: reading returns the live map value; writing updates both the attribute and the map. +## Escape hatch + +Every component exposes a `leafletObject` getter that returns the underlying Leaflet instance. This is useful when you need to call Leaflet API methods directly: + +```js +const marker = document.querySelector('leaflet-marker'); +marker.leafletObject?.setLatLng([51.5, -0.09]); + +const map = document.querySelector('leaflet-map'); +map.leafletObject?.flyTo([48.86, 2.35], 13); +``` + +Returns `undefined` while the element isn't connected to the DOM. + ### CSS Leaflet's stylesheet is loaded from a CDN via a `` in the shadow DOM. Marker icon paths are derived from the CSS URL automatically. diff --git a/index.html b/index.html index 704cd7b..a5f82bd 100644 --- a/index.html +++ b/index.html @@ -320,6 +320,13 @@ +