namazu-ts 1.2.9 → 1.2.11

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.
@@ -20757,8 +20757,10 @@ class SismoMap {
20757
20757
  _debug = false;
20758
20758
  _showDescription = true;
20759
20759
  _lang;
20760
+ _legendClasses;
20760
20761
  constructor(name, map, lang, legendClasses, bounds) {
20761
20762
  this._lang = lang;
20763
+ this._legendClasses = legendClasses;
20762
20764
  this._descPopups = [];
20763
20765
  const descPopup = new vA({
20764
20766
  closeButton: false,
@@ -20778,19 +20780,12 @@ class SismoMap {
20778
20780
  }
20779
20781
  });
20780
20782
  this.map = map;
20781
- const scale = new cA;
20782
20783
  const zoomC = new Yk({
20783
20784
  showZoom: true,
20784
20785
  showCompass: false
20785
20786
  });
20786
20787
  map.addControl(zoomC);
20787
20788
  this._zoomElem = zoomC._container;
20788
- map.addControl(scale);
20789
- scale._container.style.display = "none";
20790
- scale._container.id = "scale";
20791
- this.addMagLegend(legendClasses);
20792
- this.addContourLegend(lang, legendClasses);
20793
- this.addIntensityLegend(lang, legendClasses);
20794
20789
  map.dragRotate.disable();
20795
20790
  map.once("load", () => {
20796
20791
  if (bounds !== undefined) {
@@ -21055,6 +21050,13 @@ class SismoMap {
21055
21050
  showZoom(enabled) {
21056
21051
  this._zoomElem.style.display = enabled ? "block" : "none";
21057
21052
  }
21053
+ exec(func) {
21054
+ if (this.map.loaded() || this._usable) {
21055
+ func();
21056
+ } else {
21057
+ this.map.once("load", () => func());
21058
+ }
21059
+ }
21058
21060
  stopSpin() {
21059
21061
  this._spinEnabled = false;
21060
21062
  this.map.stop();
@@ -21241,29 +21243,24 @@ class SismoMap {
21241
21243
  clear,
21242
21244
  displayCallback
21243
21245
  }) {
21244
- function display(map) {
21246
+ this.exec(() => {
21245
21247
  if (sourceName === "stations" /* STATIONS */) {
21246
- map.map.setLayoutProperty("stations" /* STATIONS */, "visibility", "visible");
21248
+ this.map.setLayoutProperty("stations" /* STATIONS */, "visibility", "visible");
21247
21249
  }
21248
21250
  if (sourceName === "events" /* EVENTS */) {}
21249
21251
  if (clear) {
21250
- map.clear();
21252
+ this.clear();
21251
21253
  }
21252
21254
  if (geojson.features.length === 0)
21253
21255
  return;
21254
21256
  if (displayCallback) {
21255
21257
  displayCallback();
21256
21258
  }
21257
- map.updateSource(sourceName, geojson);
21259
+ this.updateSource(sourceName, geojson);
21258
21260
  if (moveView) {
21259
- map.centerView(geojson);
21261
+ this.centerView(geojson);
21260
21262
  }
21261
- }
21262
- if (this.map.loaded() || this._usable) {
21263
- display(this);
21264
- } else {
21265
- this.map.once("load", () => display(this));
21266
- }
21263
+ });
21267
21264
  }
21268
21265
  spinGlobe() {
21269
21266
  if (!this._userInteracting && this._spinEnabled && this.map.getZoom() < this._maxSpinZoom) {
@@ -21273,45 +21270,50 @@ class SismoMap {
21273
21270
  }
21274
21271
  }
21275
21272
  showScale(enabled) {
21276
- function handle() {
21277
- const legend = document.getElementById("scale");
21278
- if (legend != null) {
21279
- legend.style.display = enabled ? "block" : "none";
21273
+ this.exec(() => {
21274
+ let legend = document.getElementById("scale");
21275
+ if (!legend) {
21276
+ legend = this.addScale();
21280
21277
  }
21281
- }
21282
- if (this.map.loaded() || this._usable) {
21283
- handle();
21284
- } else {
21285
- this.map.once("load", handle);
21286
- }
21278
+ legend.style.display = enabled ? "block" : "none";
21279
+ });
21287
21280
  }
21288
21281
  showMagLegend(enabled) {
21289
- function handle() {
21290
- const legend = document.getElementById("maglegend");
21291
- if (legend != null) {
21292
- legend.style.display = enabled ? "block" : "none";
21282
+ this.exec(() => {
21283
+ let legend = document.getElementById("maglegend");
21284
+ if (!legend) {
21285
+ const container = this.addMagLegend(this._legendClasses);
21286
+ if (container.isOk()) {
21287
+ legend = container.value;
21288
+ } else {
21289
+ console.error(container.error);
21290
+ return;
21291
+ }
21293
21292
  }
21294
- }
21295
- if (this.map.loaded() || this._usable) {
21296
- handle();
21297
- } else {
21298
- this.map.once("load", handle);
21299
- }
21293
+ legend.style.display = enabled ? "block" : "none";
21294
+ });
21300
21295
  }
21301
21296
  showContourLegend(type) {
21302
21297
  if (type === "intensity" /* INTENSITY */) {
21303
21298
  this.showIntensityLegend(true);
21304
21299
  return;
21305
21300
  }
21306
- function handle(map) {
21307
- const legend = document.getElementById("contlegend");
21308
- if (legend != null) {
21309
- legend.style.display = type === false ? "none" : "block";
21301
+ this.exec(() => {
21302
+ let legend = document.getElementById("contlegend");
21303
+ if (!legend) {
21304
+ const container = this.addContourLegend(this._lang, this._legendClasses);
21305
+ if (container.isOk()) {
21306
+ legend = container.value;
21307
+ } else {
21308
+ console.error(container.error);
21309
+ return;
21310
+ }
21310
21311
  }
21312
+ legend.style.display = type === false ? "none" : "block";
21311
21313
  if (!type)
21312
21314
  return;
21313
21315
  const titles = { fr: `Intensités ${type.toUpperCase()}`, en: `${type.toUpperCase()} intensities` };
21314
- document.getElementById("contour_title").textContent = titles[map._lang];
21316
+ document.getElementById("contour_title").textContent = titles[this._lang];
21315
21317
  const texts = [
21316
21318
  { level: "I", pga: "<0.02", pgv: "<0.07", psa0p3: "<0.010", psa1p0: "<0.001", psa3p0: "<0.0008" },
21317
21319
  { level: "II", pga: "0.07", pgv: "0.03", psa0p3: "0.05", psa1p0: "0.009", psa3p0: "0.005" },
@@ -21335,25 +21337,22 @@ class SismoMap {
21335
21337
  continue;
21336
21338
  elem.textContent = text.level + " : " + text[type];
21337
21339
  }
21338
- }
21339
- if (this.map.loaded() || this._usable) {
21340
- handle(this);
21341
- } else {
21342
- this.map.once("load", () => handle(this));
21343
- }
21340
+ });
21344
21341
  }
21345
21342
  showIntensityLegend(enabled) {
21346
- function handle() {
21347
- const legend = document.getElementById("intlegend");
21348
- if (legend != null) {
21349
- legend.style.display = enabled ? "block" : "none";
21343
+ this.exec(() => {
21344
+ let legend = document.getElementById("intlegend");
21345
+ if (!legend) {
21346
+ const container = this.addIntensityLegend(this._lang, this._legendClasses);
21347
+ if (container.isOk()) {
21348
+ legend = container.value;
21349
+ } else {
21350
+ console.error(container.error);
21351
+ return;
21352
+ }
21350
21353
  }
21351
- }
21352
- if (this.map.loaded() || this._usable) {
21353
- handle();
21354
- } else {
21355
- this.map.once("load", handle);
21356
- }
21354
+ legend.style.display = enabled ? "block" : "none";
21355
+ });
21357
21356
  }
21358
21357
  addContourLegend(lang, classes) {
21359
21358
 
@@ -21403,7 +21402,16 @@ class SismoMap {
21403
21402
  this._map = undefined;
21404
21403
  }
21405
21404
  }
21406
- this.map.addControl(new ContourLegend, "bottom-right");
21405
+ const contourLegend = new ContourLegend;
21406
+ this.map.addControl(contourLegend, "bottom-right");
21407
+ return contourLegend._container !== undefined ? ok(contourLegend._container) : err(new Error("Container not present"));
21408
+ }
21409
+ addScale() {
21410
+ const scale = new cA;
21411
+ this.map.addControl(scale);
21412
+ scale._container.style.display = "none";
21413
+ scale._container.id = "scale";
21414
+ return scale._container;
21407
21415
  }
21408
21416
  addMagLegend(classes) {
21409
21417
 
@@ -21449,7 +21457,9 @@ class SismoMap {
21449
21457
  this._map = undefined;
21450
21458
  }
21451
21459
  }
21452
- this.map.addControl(new MagnitudeLegend, "bottom-right");
21460
+ const magnitudeLegend = new MagnitudeLegend;
21461
+ this.map.addControl(magnitudeLegend, "bottom-right");
21462
+ return magnitudeLegend._container !== undefined ? ok(magnitudeLegend._container) : err(new Error("Container not present"));
21453
21463
  }
21454
21464
  addIntensityLegend(locale, classes) {
21455
21465
 
@@ -21497,7 +21507,9 @@ class SismoMap {
21497
21507
  this._map = undefined;
21498
21508
  }
21499
21509
  }
21500
- this.map.addControl(new IntensityLegend, "bottom-right");
21510
+ const intensityLegend = new IntensityLegend;
21511
+ this.map.addControl(intensityLegend, "bottom-right");
21512
+ return intensityLegend._container !== undefined ? ok(intensityLegend._container) : err(new Error("Container not present"));
21501
21513
  }
21502
21514
  applyFilter(filterQuery) {
21503
21515
  if (filterQuery.magnitudes.length === 0 && filterQuery.events.length === 0) {
@@ -21551,14 +21563,14 @@ class SismoMap {
21551
21563
  linkOpacity = 1,
21552
21564
  linkWidth = 6
21553
21565
  }) {
21554
- async function display(map) {
21555
- const eventsrc = map.map.getSource("events" /* EVENTS */);
21566
+ this.exec(async () => {
21567
+ const eventsrc = this.map.getSource("events" /* EVENTS */);
21556
21568
  if (eventsrc === undefined) {
21557
21569
  console.error("Event source inexistent ?");
21558
21570
  return;
21559
21571
  }
21560
21572
  const src = await eventsrc.getData();
21561
- const statSrc = map.map.getSource("stations" /* STATIONS */);
21573
+ const statSrc = this.map.getSource("stations" /* STATIONS */);
21562
21574
  const geojson = await statSrc.getData();
21563
21575
  const stationsGeoJSON = geojson;
21564
21576
  let station;
@@ -21568,20 +21580,20 @@ class SismoMap {
21568
21580
  break;
21569
21581
  }
21570
21582
  }
21571
- map.map.setPaintProperty("ligne" /* LINE */, "line-color", linkColor);
21572
- map.map.setPaintProperty("ligne" /* LINE */, "line-opacity", linkOpacity);
21573
- map.map.setPaintProperty("ligne" /* LINE */, "line-width", linkWidth);
21583
+ this.map.setPaintProperty("ligne" /* LINE */, "line-color", linkColor);
21584
+ this.map.setPaintProperty("ligne" /* LINE */, "line-opacity", linkOpacity);
21585
+ this.map.setPaintProperty("ligne" /* LINE */, "line-width", linkWidth);
21574
21586
  if (station === undefined) {
21575
- if (map._debug) {
21587
+ if (this._debug) {
21576
21588
  console.log("no stations with code " + phase.stationCode);
21577
21589
  }
21578
21590
  return Promise.resolve();
21579
21591
  }
21580
21592
  const event = src.features[0];
21581
- map._descPopups[1].setLngLat(station.geometry.coordinates).setText(popupString).addTo(map.map);
21582
- map._descPopups[1].getElement().style.color = "black";
21583
- map._descPopups[1].getElement().style.pointerEvents = "none !important";
21584
- map._descPopups[1].getElement().querySelectorAll("*").forEach((el2) => {
21593
+ this._descPopups[1].setLngLat(station.geometry.coordinates).setText(popupString).addTo(this.map);
21594
+ this._descPopups[1].getElement().style.color = "black";
21595
+ this._descPopups[1].getElement().style.pointerEvents = "none !important";
21596
+ this._descPopups[1].getElement().querySelectorAll("*").forEach((el2) => {
21585
21597
  el2.style.pointerEvents = "none";
21586
21598
  });
21587
21599
  const newData = {
@@ -21595,13 +21607,8 @@ class SismoMap {
21595
21607
  ]
21596
21608
  }
21597
21609
  };
21598
- map.map.getSource("ligne" /* LINE */)?.setData(newData);
21599
- }
21600
- if (this.map.loaded() || this._usable) {
21601
- display(this);
21602
- } else {
21603
- this.map.once("load", () => display(this));
21604
- }
21610
+ this.map.getSource("ligne" /* LINE */)?.setData(newData);
21611
+ });
21605
21612
  }
21606
21613
  displayRect({
21607
21614
  minlng,
@@ -21649,7 +21656,7 @@ class SismoMap {
21649
21656
  "place_village",
21650
21657
  "place_city_capital"
21651
21658
  ];
21652
- this.map.once("load", () => {
21659
+ this.exec(() => {
21653
21660
  layersToChange.forEach((layer) => {
21654
21661
  this.map.setLayoutProperty(layer, "text-field", [
21655
21662
  "get",
@@ -21658,13 +21665,6 @@ class SismoMap {
21658
21665
  });
21659
21666
  });
21660
21667
  }
21661
- async getEventNumber() {
21662
- const source = this.map.getSource("events" /* EVENTS */);
21663
- if (source === undefined)
21664
- return Promise.reject(-1);
21665
- const sourceData = await source.getData();
21666
- return sourceData.features.length;
21667
- }
21668
21668
  }
21669
21669
  export {
21670
21670
  isEventGeoJSONProperties,
@@ -33865,8 +33865,10 @@ class SismoMap {
33865
33865
  _debug = false;
33866
33866
  _showDescription = true;
33867
33867
  _lang;
33868
+ _legendClasses;
33868
33869
  constructor(name, map, lang, legendClasses, bounds) {
33869
33870
  this._lang = lang;
33871
+ this._legendClasses = legendClasses;
33870
33872
  this._descPopups = [];
33871
33873
  const descPopup = new vA({
33872
33874
  closeButton: false,
@@ -33886,19 +33888,12 @@ class SismoMap {
33886
33888
  }
33887
33889
  });
33888
33890
  this.map = map;
33889
- const scale = new cA;
33890
33891
  const zoomC = new Yk({
33891
33892
  showZoom: true,
33892
33893
  showCompass: false
33893
33894
  });
33894
33895
  map.addControl(zoomC);
33895
33896
  this._zoomElem = zoomC._container;
33896
- map.addControl(scale);
33897
- scale._container.style.display = "none";
33898
- scale._container.id = "scale";
33899
- this.addMagLegend(legendClasses);
33900
- this.addContourLegend(lang, legendClasses);
33901
- this.addIntensityLegend(lang, legendClasses);
33902
33897
  map.dragRotate.disable();
33903
33898
  map.once("load", () => {
33904
33899
  if (bounds !== undefined) {
@@ -34163,6 +34158,13 @@ class SismoMap {
34163
34158
  showZoom(enabled) {
34164
34159
  this._zoomElem.style.display = enabled ? "block" : "none";
34165
34160
  }
34161
+ exec(func) {
34162
+ if (this.map.loaded() || this._usable) {
34163
+ func();
34164
+ } else {
34165
+ this.map.once("load", () => func());
34166
+ }
34167
+ }
34166
34168
  stopSpin() {
34167
34169
  this._spinEnabled = false;
34168
34170
  this.map.stop();
@@ -34349,29 +34351,24 @@ class SismoMap {
34349
34351
  clear,
34350
34352
  displayCallback
34351
34353
  }) {
34352
- function display(map) {
34354
+ this.exec(() => {
34353
34355
  if (sourceName === "stations" /* STATIONS */) {
34354
- map.map.setLayoutProperty("stations" /* STATIONS */, "visibility", "visible");
34356
+ this.map.setLayoutProperty("stations" /* STATIONS */, "visibility", "visible");
34355
34357
  }
34356
34358
  if (sourceName === "events" /* EVENTS */) {}
34357
34359
  if (clear) {
34358
- map.clear();
34360
+ this.clear();
34359
34361
  }
34360
34362
  if (geojson.features.length === 0)
34361
34363
  return;
34362
34364
  if (displayCallback) {
34363
34365
  displayCallback();
34364
34366
  }
34365
- map.updateSource(sourceName, geojson);
34367
+ this.updateSource(sourceName, geojson);
34366
34368
  if (moveView) {
34367
- map.centerView(geojson);
34369
+ this.centerView(geojson);
34368
34370
  }
34369
- }
34370
- if (this.map.loaded() || this._usable) {
34371
- display(this);
34372
- } else {
34373
- this.map.once("load", () => display(this));
34374
- }
34371
+ });
34375
34372
  }
34376
34373
  spinGlobe() {
34377
34374
  if (!this._userInteracting && this._spinEnabled && this.map.getZoom() < this._maxSpinZoom) {
@@ -34381,45 +34378,50 @@ class SismoMap {
34381
34378
  }
34382
34379
  }
34383
34380
  showScale(enabled) {
34384
- function handle() {
34385
- const legend = document.getElementById("scale");
34386
- if (legend != null) {
34387
- legend.style.display = enabled ? "block" : "none";
34381
+ this.exec(() => {
34382
+ let legend = document.getElementById("scale");
34383
+ if (!legend) {
34384
+ legend = this.addScale();
34388
34385
  }
34389
- }
34390
- if (this.map.loaded() || this._usable) {
34391
- handle();
34392
- } else {
34393
- this.map.once("load", handle);
34394
- }
34386
+ legend.style.display = enabled ? "block" : "none";
34387
+ });
34395
34388
  }
34396
34389
  showMagLegend(enabled) {
34397
- function handle() {
34398
- const legend = document.getElementById("maglegend");
34399
- if (legend != null) {
34400
- legend.style.display = enabled ? "block" : "none";
34390
+ this.exec(() => {
34391
+ let legend = document.getElementById("maglegend");
34392
+ if (!legend) {
34393
+ const container = this.addMagLegend(this._legendClasses);
34394
+ if (container.isOk()) {
34395
+ legend = container.value;
34396
+ } else {
34397
+ console.error(container.error);
34398
+ return;
34399
+ }
34401
34400
  }
34402
- }
34403
- if (this.map.loaded() || this._usable) {
34404
- handle();
34405
- } else {
34406
- this.map.once("load", handle);
34407
- }
34401
+ legend.style.display = enabled ? "block" : "none";
34402
+ });
34408
34403
  }
34409
34404
  showContourLegend(type) {
34410
34405
  if (type === "intensity" /* INTENSITY */) {
34411
34406
  this.showIntensityLegend(true);
34412
34407
  return;
34413
34408
  }
34414
- function handle(map) {
34415
- const legend = document.getElementById("contlegend");
34416
- if (legend != null) {
34417
- legend.style.display = type === false ? "none" : "block";
34409
+ this.exec(() => {
34410
+ let legend = document.getElementById("contlegend");
34411
+ if (!legend) {
34412
+ const container = this.addContourLegend(this._lang, this._legendClasses);
34413
+ if (container.isOk()) {
34414
+ legend = container.value;
34415
+ } else {
34416
+ console.error(container.error);
34417
+ return;
34418
+ }
34418
34419
  }
34420
+ legend.style.display = type === false ? "none" : "block";
34419
34421
  if (!type)
34420
34422
  return;
34421
34423
  const titles = { fr: `Intensités ${type.toUpperCase()}`, en: `${type.toUpperCase()} intensities` };
34422
- document.getElementById("contour_title").textContent = titles[map._lang];
34424
+ document.getElementById("contour_title").textContent = titles[this._lang];
34423
34425
  const texts = [
34424
34426
  { level: "I", pga: "<0.02", pgv: "<0.07", psa0p3: "<0.010", psa1p0: "<0.001", psa3p0: "<0.0008" },
34425
34427
  { level: "II", pga: "0.07", pgv: "0.03", psa0p3: "0.05", psa1p0: "0.009", psa3p0: "0.005" },
@@ -34443,25 +34445,22 @@ class SismoMap {
34443
34445
  continue;
34444
34446
  elem.textContent = text.level + " : " + text[type];
34445
34447
  }
34446
- }
34447
- if (this.map.loaded() || this._usable) {
34448
- handle(this);
34449
- } else {
34450
- this.map.once("load", () => handle(this));
34451
- }
34448
+ });
34452
34449
  }
34453
34450
  showIntensityLegend(enabled) {
34454
- function handle() {
34455
- const legend = document.getElementById("intlegend");
34456
- if (legend != null) {
34457
- legend.style.display = enabled ? "block" : "none";
34451
+ this.exec(() => {
34452
+ let legend = document.getElementById("intlegend");
34453
+ if (!legend) {
34454
+ const container = this.addIntensityLegend(this._lang, this._legendClasses);
34455
+ if (container.isOk()) {
34456
+ legend = container.value;
34457
+ } else {
34458
+ console.error(container.error);
34459
+ return;
34460
+ }
34458
34461
  }
34459
- }
34460
- if (this.map.loaded() || this._usable) {
34461
- handle();
34462
- } else {
34463
- this.map.once("load", handle);
34464
- }
34462
+ legend.style.display = enabled ? "block" : "none";
34463
+ });
34465
34464
  }
34466
34465
  addContourLegend(lang, classes) {
34467
34466
 
@@ -34511,7 +34510,16 @@ class SismoMap {
34511
34510
  this._map = undefined;
34512
34511
  }
34513
34512
  }
34514
- this.map.addControl(new ContourLegend, "bottom-right");
34513
+ const contourLegend = new ContourLegend;
34514
+ this.map.addControl(contourLegend, "bottom-right");
34515
+ return contourLegend._container !== undefined ? $ok(contourLegend._container) : $err(new Error("Container not present"));
34516
+ }
34517
+ addScale() {
34518
+ const scale = new cA;
34519
+ this.map.addControl(scale);
34520
+ scale._container.style.display = "none";
34521
+ scale._container.id = "scale";
34522
+ return scale._container;
34515
34523
  }
34516
34524
  addMagLegend(classes) {
34517
34525
 
@@ -34557,7 +34565,9 @@ class SismoMap {
34557
34565
  this._map = undefined;
34558
34566
  }
34559
34567
  }
34560
- this.map.addControl(new MagnitudeLegend, "bottom-right");
34568
+ const magnitudeLegend = new MagnitudeLegend;
34569
+ this.map.addControl(magnitudeLegend, "bottom-right");
34570
+ return magnitudeLegend._container !== undefined ? $ok(magnitudeLegend._container) : $err(new Error("Container not present"));
34561
34571
  }
34562
34572
  addIntensityLegend(locale, classes) {
34563
34573
 
@@ -34605,7 +34615,9 @@ class SismoMap {
34605
34615
  this._map = undefined;
34606
34616
  }
34607
34617
  }
34608
- this.map.addControl(new IntensityLegend, "bottom-right");
34618
+ const intensityLegend = new IntensityLegend;
34619
+ this.map.addControl(intensityLegend, "bottom-right");
34620
+ return intensityLegend._container !== undefined ? $ok(intensityLegend._container) : $err(new Error("Container not present"));
34609
34621
  }
34610
34622
  applyFilter(filterQuery) {
34611
34623
  if (filterQuery.magnitudes.length === 0 && filterQuery.events.length === 0) {
@@ -34659,14 +34671,14 @@ class SismoMap {
34659
34671
  linkOpacity = 1,
34660
34672
  linkWidth = 6
34661
34673
  }) {
34662
- async function display(map) {
34663
- const eventsrc = map.map.getSource("events" /* EVENTS */);
34674
+ this.exec(async () => {
34675
+ const eventsrc = this.map.getSource("events" /* EVENTS */);
34664
34676
  if (eventsrc === undefined) {
34665
34677
  console.error("Event source inexistent ?");
34666
34678
  return;
34667
34679
  }
34668
34680
  const src = await eventsrc.getData();
34669
- const statSrc = map.map.getSource("stations" /* STATIONS */);
34681
+ const statSrc = this.map.getSource("stations" /* STATIONS */);
34670
34682
  const geojson = await statSrc.getData();
34671
34683
  const stationsGeoJSON = geojson;
34672
34684
  let station;
@@ -34676,20 +34688,20 @@ class SismoMap {
34676
34688
  break;
34677
34689
  }
34678
34690
  }
34679
- map.map.setPaintProperty("ligne" /* LINE */, "line-color", linkColor);
34680
- map.map.setPaintProperty("ligne" /* LINE */, "line-opacity", linkOpacity);
34681
- map.map.setPaintProperty("ligne" /* LINE */, "line-width", linkWidth);
34691
+ this.map.setPaintProperty("ligne" /* LINE */, "line-color", linkColor);
34692
+ this.map.setPaintProperty("ligne" /* LINE */, "line-opacity", linkOpacity);
34693
+ this.map.setPaintProperty("ligne" /* LINE */, "line-width", linkWidth);
34682
34694
  if (station === undefined) {
34683
- if (map._debug) {
34695
+ if (this._debug) {
34684
34696
  console.log("no stations with code " + phase.stationCode);
34685
34697
  }
34686
34698
  return Promise.resolve();
34687
34699
  }
34688
34700
  const event = src.features[0];
34689
- map._descPopups[1].setLngLat(station.geometry.coordinates).setText(popupString).addTo(map.map);
34690
- map._descPopups[1].getElement().style.color = "black";
34691
- map._descPopups[1].getElement().style.pointerEvents = "none !important";
34692
- map._descPopups[1].getElement().querySelectorAll("*").forEach((el2) => {
34701
+ this._descPopups[1].setLngLat(station.geometry.coordinates).setText(popupString).addTo(this.map);
34702
+ this._descPopups[1].getElement().style.color = "black";
34703
+ this._descPopups[1].getElement().style.pointerEvents = "none !important";
34704
+ this._descPopups[1].getElement().querySelectorAll("*").forEach((el2) => {
34693
34705
  el2.style.pointerEvents = "none";
34694
34706
  });
34695
34707
  const newData = {
@@ -34703,13 +34715,8 @@ class SismoMap {
34703
34715
  ]
34704
34716
  }
34705
34717
  };
34706
- map.map.getSource("ligne" /* LINE */)?.setData(newData);
34707
- }
34708
- if (this.map.loaded() || this._usable) {
34709
- display(this);
34710
- } else {
34711
- this.map.once("load", () => display(this));
34712
- }
34718
+ this.map.getSource("ligne" /* LINE */)?.setData(newData);
34719
+ });
34713
34720
  }
34714
34721
  displayRect({
34715
34722
  minlng,
@@ -34757,7 +34764,7 @@ class SismoMap {
34757
34764
  "place_village",
34758
34765
  "place_city_capital"
34759
34766
  ];
34760
- this.map.once("load", () => {
34767
+ this.exec(() => {
34761
34768
  layersToChange.forEach((layer) => {
34762
34769
  this.map.setLayoutProperty(layer, "text-field", [
34763
34770
  "get",
@@ -34766,13 +34773,6 @@ class SismoMap {
34766
34773
  });
34767
34774
  });
34768
34775
  }
34769
- async getEventNumber() {
34770
- const source = this.map.getSource("events" /* EVENTS */);
34771
- if (source === undefined)
34772
- return Promise.reject(-1);
34773
- const sourceData = await source.getData();
34774
- return sourceData.features.length;
34775
- }
34776
34776
  }
34777
34777
  export {
34778
34778
  isEventGeoJSONProperties,
@@ -18,6 +18,7 @@ export declare class SismoMap {
18
18
  _debug: boolean;
19
19
  _showDescription: boolean;
20
20
  _lang: string;
21
+ _legendClasses: string[] | undefined;
21
22
  constructor(name: string, map: maplibregl.Map, lang: string, legendClasses?: string[], bounds?: maplibregl.LngLatBoundsLike);
22
23
  /**
23
24
  * Clears all user-made layers
@@ -29,6 +30,11 @@ export declare class SismoMap {
29
30
  setDebug(mode: boolean): void;
30
31
  setZoomModeCenter(shouldCenterZoom: boolean): void;
31
32
  showZoom(enabled: boolean): void;
33
+ /**
34
+ * Whenever you need to write code that interacts with the map (like the layers or source), run the code inside map.exec
35
+ * It prevents the code from executing if the map isn't ready in any way and executes it as soon as it can.
36
+ */
37
+ exec(func: () => void): void;
32
38
  stopSpin(): void;
33
39
  startSpin(): void;
34
40
  setInteractive(interactive: boolean): void;
@@ -87,6 +93,7 @@ export declare class SismoMap {
87
93
  showContourLegend(type: ContourType | false): void;
88
94
  showIntensityLegend(enabled: boolean): void;
89
95
  private addContourLegend;
96
+ private addScale;
90
97
  private addMagLegend;
91
98
  private addIntensityLegend;
92
99
  /**
@@ -141,5 +148,4 @@ export declare class SismoMap {
141
148
  }): void;
142
149
  displayPolygon(coords: number[][]): void;
143
150
  changeLanguage(lang: string): void;
144
- getEventNumber(): Promise<number>;
145
151
  }