@watergis/maplibre-gl-terradraw 1.3.8 → 1.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4264,27 +4264,27 @@ class Fo {
4264
4264
  * @returns HTML Element
4265
4265
  */
4266
4266
  onAdd(t) {
4267
- var o, r, n, a, l;
4267
+ var o, r, n, a, l, d, h;
4268
4268
  if (this.options && this.options.modes && this.options.modes.length === 0)
4269
4269
  throw new Error("At least a mode must be enabled.");
4270
4270
  this.map = t;
4271
4271
  const e = Ji(), i = [];
4272
- return (r = (o = this.options) == null ? void 0 : o.modes) == null || r.forEach((d) => {
4273
- if (this.options.modeOptions && this.options.modeOptions[d]) {
4274
- const h = this.options.modeOptions[d];
4275
- if (d === "select") {
4276
- const c = e[d];
4277
- if (c) {
4278
- const u = c.flags;
4279
- Object.keys(u).forEach((p) => {
4280
- h.flags[p] || (h.flags[p] = u[p]);
4272
+ return (r = (o = this.options) == null ? void 0 : o.modes) == null || r.forEach((c) => {
4273
+ if (this.options.modeOptions && this.options.modeOptions[c]) {
4274
+ const u = this.options.modeOptions[c];
4275
+ if (c === "select") {
4276
+ const p = e[c];
4277
+ if (p) {
4278
+ const g = p.flags;
4279
+ Object.keys(g).forEach((y) => {
4280
+ u.flags[y] || (u.flags[y] = g[y]);
4281
4281
  });
4282
4282
  }
4283
4283
  }
4284
- i.push(h);
4285
- } else e[d] && i.push(e[d]);
4286
- }), i.forEach((d) => {
4287
- d.state !== "unregistered" && (d._state = "unregistered");
4284
+ i.push(u);
4285
+ } else e[c] && i.push(e[c]);
4286
+ }), i.forEach((c) => {
4287
+ c.state !== "unregistered" && (c._state = "unregistered");
4288
4288
  }), (a = (n = this.options) == null ? void 0 : n.modes) != null && a.includes("render") || (i.push(
4289
4289
  new et({
4290
4290
  modeName: "default",
@@ -4293,12 +4293,15 @@ class Fo {
4293
4293
  ), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new $i({
4294
4294
  adapter: new Yi({ map: t, ...this.options.adapterOptions }),
4295
4295
  modes: i
4296
- }), this.terradraw.start(), this.controlContainer = document.createElement("div"), this.controlContainer.classList.add("maplibregl-ctrl"), this.controlContainer.classList.add("maplibregl-ctrl-group"), i.forEach((d) => {
4297
- d.mode !== "default" && this.addTerradrawButton(d.mode);
4298
- }), Object.values(this.modeButtons).forEach((d) => {
4299
- var h;
4300
- (h = this.controlContainer) == null || h.appendChild(d);
4301
- }), (l = this.terradraw) == null || l.on("change", this.toggleButtonsWhenNoFeature.bind(this)), this.toggleButtonsWhenNoFeature(), this.controlContainer;
4296
+ }), (l = this.map) != null && l.loaded() ? this.terradraw.start() : (d = this.map) == null || d.once("load", () => {
4297
+ var c;
4298
+ (c = this.terradraw) == null || c.start();
4299
+ }), this.controlContainer = document.createElement("div"), this.controlContainer.classList.add("maplibregl-ctrl"), this.controlContainer.classList.add("maplibregl-ctrl-group"), i.forEach((c) => {
4300
+ c.mode !== "default" && this.addTerradrawButton(c.mode);
4301
+ }), Object.values(this.modeButtons).forEach((c) => {
4302
+ var u;
4303
+ (u = this.controlContainer) == null || u.appendChild(c);
4304
+ }), (h = this.terradraw) == null || h.on("change", this.toggleButtonsWhenNoFeature.bind(this)), this.toggleButtonsWhenNoFeature(), this.controlContainer;
4302
4305
  }
4303
4306
  /**
4304
4307
  * Remove the plugin control from maplibre