leaflet-html 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,5 @@
1
+ // @ts-check
2
+ import { tileLayer } from "leaflet";
1
3
  import { mapAddTo } from "./events.js";
2
4
 
3
5
  class LTileLayer extends HTMLElement {
@@ -8,9 +10,15 @@ class LTileLayer extends HTMLElement {
8
10
  connectedCallback() {
9
11
  const name = this.getAttribute("name");
10
12
  const urlTemplate = this.getAttribute("url-template");
11
- const attribution = this.getAttribute("attribution");
12
- const options = { attribution };
13
- const layer = L.tileLayer(urlTemplate, options);
13
+ if (urlTemplate === null) {
14
+ return;
15
+ }
16
+ const options = {};
17
+ const key = "attribution";
18
+ if (this.hasAttribute(key)) {
19
+ options[key] = this.getAttribute(key);
20
+ }
21
+ const layer = tileLayer(urlTemplate, options);
14
22
  const event = new CustomEvent(mapAddTo, {
15
23
  detail: { name, layer },
16
24
  bubbles: true,
@@ -1,3 +1,5 @@
1
+ // @ts-check
2
+ import { videoOverlay } from "leaflet";
1
3
  import { mapAddTo } from "./events.js";
2
4
 
3
5
  class LVideoOverlay extends HTMLElement {
@@ -15,7 +17,7 @@ class LVideoOverlay extends HTMLElement {
15
17
  muted: true,
16
18
  playsInline: true,
17
19
  };
18
- const layer = L.videoOverlay(url, bounds, options);
20
+ const layer = videoOverlay(url, bounds, options);
19
21
  this.dispatchEvent(
20
22
  new CustomEvent(mapAddTo, {
21
23
  cancelable: true,