UNPKG

astro-leaflet

Version:

Leaflet astro component, to display maps: Google Maps, Openstreetmap, maps from Michelin, googlemaps, Open Street Map...

21 lines (17 loc) 635 B
// Copyright (c) Pascal Brand // MIT License import { polyline as Lpolyline } from "leaflet/dist/leaflet-src.esm" import type { AstroLeafletPolylineType } from '../../index' import type { Polyline } from 'leaflet' import { getMapFromElement } from '../../index' export class CustomElementPolyline extends HTMLElement { leafletElement: Polyline | undefined constructor() { super() const props: AstroLeafletPolylineType = JSON.parse(this.dataset.props!) const map = getMapFromElement(this) if (map) { this.leafletElement = Lpolyline(props.latlngs, props.options).addTo(map!); } } }