leaflet-components/index.html
Buddy 6b448ba092 feat: Initial implementation of leaflet-components
Wraps Leaflet.js as native Web Components. Each element maps 1:1 to a
Leaflet object with reactive attribute binding and proper lifecycle cleanup.

Key design decisions:
- LeafletElement base class handles attribute→option mapping, the
  leaflet-register bubble event for parent/child wiring, and
  disconnectedCallback cleanup tracking parent bindings.
- LeafletControl base class for map controls (zoom, attribution, scale).
- leaflet-map uses a PROPS table to drive observedAttributes, getters/setters,
  attributeChangedCallback, and map event listeners from a single source of
  truth. Property types are derived via a mapped type over the table; the
  mixin-base pattern (TypedBase) makes them visible to TypeScript without an
  interface merge.
- Boolean map options that default to true use disable-* attributes.
- Leaflet and its CSS are bundled into dist/index.js via esbuild.
- JSR config included for @buddy/leaflet-components.
2026-06-06 14:08:53 -07:00

75 lines
2.4 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Leaflet Components Demo</title>
<style>
body {
margin: 0;
padding: 20px;
font-family: sans-serif;
}
leaflet-map {
height: 500px;
border: 1px solid #ccc;
}
</style>
</head>
<body>
<h1>Leaflet Web Components</h1>
<leaflet-map lat="51.505" lng="-0.09" zoom="13">
<leaflet-tile-layer
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
attribution="&copy; <a href='https://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors"
>
</leaflet-tile-layer>
<leaflet-marker lat="51.505" lng="-0.09" title="A Marker">
<leaflet-popup><b>Hello world!</b><br />I am a popup.</leaflet-popup>
<leaflet-tooltip>I am a tooltip</leaflet-tooltip>
</leaflet-marker>
<leaflet-circle
lat="51.508"
lng="-0.11"
color="red"
fill-color="#f03"
fill-opacity="0.5"
radius="500"
>
<leaflet-popup>I am a circle.</leaflet-popup>
</leaflet-circle>
<leaflet-polygon color="blue" fill-color="cyan" fill-opacity="0.3">
<leaflet-line lat="51.509" lng="-0.08"></leaflet-line>
<leaflet-line lat="51.503" lng="-0.06"></leaflet-line>
<leaflet-line lat="51.51" lng="-0.047"></leaflet-line>
<leaflet-popup>I am a polygon.</leaflet-popup>
</leaflet-polygon>
<leaflet-feature-group>
<leaflet-marker lat="51.513" lng="-0.07" title="Feature Group Marker">
<leaflet-tooltip>Part of a feature group</leaflet-tooltip>
</leaflet-marker>
<leaflet-circle lat="51.513" lng="-0.07" radius="100" color="purple" fill-color="purple" fill-opacity="0.2">
</leaflet-circle>
</leaflet-feature-group>
<leaflet-geojson
color="#e67e22"
weight="3"
fill-color="#f39c12"
fill-opacity="0.4"
data='{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-0.13,51.50],[-0.12,51.50],[-0.12,51.51],[-0.13,51.51],[-0.13,51.50]]]},"properties":{}}'
></leaflet-geojson>
<leaflet-control-scale position="bottomleft"></leaflet-control-scale>
</leaflet-map>
<!-- script type="module" src="./src/index.ts"></script -->
<script type="module" src="/dist/index.js"></script>
</body>
</html>