andrewgryan / leaflet-html

Leaflet JS maps expressed in HTML suitable for HTMX and hypermedia driven applications
https://andrewgryan.github.io/leaflet-html/
MIT License
8 stars 2 forks source link

L.TileLayer.WMS support #45

Open andrewgryan opened 2 weeks ago

andrewgryan commented 2 weeks ago

Add support for <l-tile-layer-wms> Custom Element.

Useful links

andrewgryan commented 1 week ago

Potential design to support non-standard WMS parameters. Use JSON in a dedicated options attribute.

<l-tile-layer-wms
    base-url="/wms/path"
    layers="wms_layer_name"
    styles="wms_style"
    options='{"key": "value"}'
></l-tile-layer-wms>

Internal to the component, the options and standard attributes can be parsed and combined.

// connectedCallback
// Error handling omitted

const layers = this.getAttribute("layers")
const styles = this.getAttribute("styles")
const options = JSON.parse(
    this.getAttribute("options")
)

this.layer = TileLayer.WMS(baseUrl,
    { layers, styles, ...options}
)