solid-map-gl 2.2.0 → 2.2.2

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.
@@ -1,38 +1,19 @@
1
+ import {
2
+ MapProvider,
3
+ useMapContext
4
+ } from "../chunk/N4NHJCAS.jsx";
5
+
1
6
  // src/components/MapGL/index.tsx
2
7
  import {
3
8
  createSignal,
4
- createEffect as createEffect2,
9
+ createEffect,
5
10
  onMount,
6
11
  onCleanup,
7
12
  on
8
13
  } from "solid-js";
9
14
  import { isServer } from "solid-js/web";
10
15
 
11
- // src/components/MapProvider/index.tsx
12
- import { createContext, useContext, createEffect } from "solid-js";
13
- import { createStore } from "solid-js/store";
14
- var defaultState = {
15
- map: null,
16
- mapLib: null,
17
- isMapLibre: false,
18
- constants: {},
19
- themeVersion: 0
20
- };
21
- var MapContext = createContext([defaultState]);
22
- var useMapContext = () => useContext(MapContext);
23
- var MapProvider = (props) => {
24
- const [state, setState] = createStore({ ...defaultState });
25
- props.map && setState("map", props.map);
26
- props.mapLib && setState("mapLib", props.mapLib);
27
- setState("isMapLibre", !!props.isMapLibre);
28
- setState("constants", props.constants || {});
29
- setState("themeVersion", props.themeVersion || 0);
30
- createEffect(() => setState("constants", props.constants || {}));
31
- createEffect(() => setState("themeVersion", props.themeVersion || 0));
32
- return <MapContext.Provider value={[state]}>{props.children}</MapContext.Provider>;
33
- };
34
-
35
- // src/events.ts
16
+ // src/lib/events.ts
36
17
  var mapEvents = [
37
18
  "onMouseDown",
38
19
  "onMouseUp",
@@ -111,7 +92,7 @@ var drawEvents = [
111
92
  "onActionable"
112
93
  ];
113
94
 
114
- // src/mapStyles.ts
95
+ // src/lib/mapStyles.ts
115
96
  var mapBase = "mapbox://styles/mapbox";
116
97
  var gitBase = "https://raw.githubusercontent.com/";
117
98
  var gishub = "https://raw.githubusercontent.com/GIShub4/map-styles/main/";
@@ -229,7 +210,7 @@ var rasterStyleList = {
229
210
  }
230
211
  };
231
212
 
232
- // src/tilesSettled.ts
213
+ // src/components/MapGL/tilesSettled.ts
233
214
  var nextFrame = () => new Promise((resolve) => requestAnimationFrame(() => resolve()));
234
215
  var hasActiveFadeTransition = (map) => {
235
216
  try {
@@ -278,6 +259,7 @@ function waitForIdleAndSettle(map, options = {}) {
278
259
  map.once("idle", () => {
279
260
  settleAfterIdle(map, options).then(resolve);
280
261
  });
262
+ map.triggerRepaint();
281
263
  });
282
264
  }
283
265
  function disableRasterFade(map) {
@@ -289,7 +271,7 @@ function disableRasterFade(map) {
289
271
  }
290
272
  }
291
273
 
292
- // src/offscreenCapture.ts
274
+ // src/components/MapGL/offscreenCapture.ts
293
275
  function createCapturer(map, settleOptions) {
294
276
  return {
295
277
  map,
@@ -328,6 +310,14 @@ var MapGL = (props) => {
328
310
  ) || style : style;
329
311
  };
330
312
  onMount(async () => {
313
+ try {
314
+ await setupMap();
315
+ } catch (error) {
316
+ console.error("[MapGL] Failed to initialize map:", error);
317
+ props.onError?.(error);
318
+ }
319
+ });
320
+ const setupMap = async () => {
331
321
  mapLib = props.mapLib || await import("mapbox-gl");
332
322
  if (!mapLib.Map) mapLib = window["maplibregl"] || window["mapboxgl"];
333
323
  if (typeof mapLib.supported === "function" && !mapLib.supported())
@@ -361,7 +351,7 @@ var MapGL = (props) => {
361
351
  if (typeof prop === "function") {
362
352
  map.on(event, (evt) => {
363
353
  setTimeout(() => {
364
- if (evt.clickOnLayer) return;
354
+ if (event === "click" && evt.clickOnLayer) return;
365
355
  prop(evt);
366
356
  props.debugEvents && debug(`Map '${event}' event:`, evt);
367
357
  }, 0);
@@ -370,7 +360,7 @@ var MapGL = (props) => {
370
360
  Object.keys(prop).forEach((layerId) => {
371
361
  map.on(event, layerId, (evt) => {
372
362
  setTimeout(() => {
373
- if (evt.clickOnLayer) return;
363
+ if (event === "click" && evt.clickOnLayer) return;
374
364
  prop[layerId](evt);
375
365
  props.debugEvents && debug(`Map '${event}' event on '${layerId}':`, evt);
376
366
  }, 0);
@@ -394,9 +384,9 @@ var MapGL = (props) => {
394
384
  map.once("load", () => {
395
385
  setMapLoaded(map);
396
386
  debug("Map loaded");
397
- if (props.offscreen) {
398
- if (props.offscreen.disableRasterFade !== false) disableRasterFade(map);
399
- props.onCapturerReady?.(
387
+ if (props.offscreen && props.offscreen.disableRasterFade !== false) disableRasterFade(map);
388
+ if (props.onCapturerReady) {
389
+ props.onCapturerReady(
400
390
  createCapturer(map, {
401
391
  timeout: props.tilesLoadedTimeout ?? 1e4,
402
392
  fadeMargin: props.tilesLoadedFadeMargin ?? 400
@@ -481,12 +471,12 @@ var MapGL = (props) => {
481
471
  props.onViewportChange(viewport);
482
472
  });
483
473
  });
484
- });
485
- createEffect2(
474
+ };
475
+ createEffect(
486
476
  on(
487
477
  () => props.viewport,
488
478
  (vp) => {
489
- if (props.id !== vp?.id) return;
479
+ if (!map || props.id !== vp?.id) return;
490
480
  if (expectingOwnEcho) {
491
481
  expectingOwnEcho = false;
492
482
  return;
@@ -511,7 +501,7 @@ var MapGL = (props) => {
511
501
  { defer: true }
512
502
  )
513
503
  );
514
- createEffect2(() => {
504
+ createEffect(() => {
515
505
  const loadedMap = mapLoaded();
516
506
  if (typeof loadedMap?.setConfigProperty !== "function") {
517
507
  if (loadedMap && props.config && Object.keys(props.config).length) {
@@ -529,13 +519,13 @@ var MapGL = (props) => {
529
519
  debug(`Set Config (${id}:${key}) to:`, value);
530
520
  }
531
521
  });
532
- createEffect2(() => {
522
+ createEffect(() => {
533
523
  const proj = props.options?.projection;
534
524
  if (!map || !proj) return;
535
525
  map.setProjection(proj);
536
526
  debug("Set Projection to:", proj);
537
527
  });
538
- createEffect2(() => {
528
+ createEffect(() => {
539
529
  const cur = props.cursorStyle;
540
530
  if (!map || !cur) return;
541
531
  map.getCanvas().style.cursor = cur;
@@ -550,7 +540,7 @@ var MapGL = (props) => {
550
540
  });
551
541
  return list;
552
542
  };
553
- createEffect2((prev) => {
543
+ createEffect((prev) => {
554
544
  const style = getStyle(props.options?.style, props.darkStyle);
555
545
  if (map?.isStyleLoaded() && prev !== style) {
556
546
  const oldStyle = map.getStyle();
@@ -583,7 +573,7 @@ var MapGL = (props) => {
583
573
  "showPadding",
584
574
  "showOverdrawInspector"
585
575
  ].forEach((item) => {
586
- createEffect2(() => {
576
+ createEffect(() => {
587
577
  const prop = props[item];
588
578
  if (!map || !prop) return;
589
579
  map[item] = prop;
@@ -627,13 +617,13 @@ var MapGL = (props) => {
627
617
  // src/components/Source/index.tsx
628
618
  import {
629
619
  onCleanup as onCleanup2,
630
- createEffect as createEffect3,
631
- createContext as createContext2,
632
- useContext as useContext2,
620
+ createEffect as createEffect2,
621
+ createContext,
622
+ useContext,
633
623
  createUniqueId
634
624
  } from "solid-js";
635
- var SourceContext = createContext2();
636
- var useSourceId = () => useContext2(SourceContext);
625
+ var SourceContext = createContext();
626
+ var useSourceId = () => useContext(SourceContext);
637
627
  var Source = (props) => {
638
628
  const [ctx] = useMapContext();
639
629
  props.id ??= createUniqueId();
@@ -665,14 +655,14 @@ var Source = (props) => {
665
655
  debug("Add Source:", props.id);
666
656
  switch (anySource().type) {
667
657
  case "geojson":
668
- createEffect3(() => {
658
+ createEffect2(() => {
669
659
  const data = anySource().data;
670
660
  ctx.map.getSource(props.id).setData(data || {});
671
661
  debug("Update GeoJSON Data:", props.id);
672
662
  });
673
663
  break;
674
664
  case "image":
675
- createEffect3(() => {
665
+ createEffect2(() => {
676
666
  const url = anySource().url;
677
667
  const coords = anySource().coordinates;
678
668
  ctx.map.getSource(props.id).updateImage(url, coords);
@@ -680,7 +670,7 @@ var Source = (props) => {
680
670
  });
681
671
  break;
682
672
  case "vector":
683
- createEffect3(() => {
673
+ createEffect2(() => {
684
674
  const url = anySource().url;
685
675
  const tiles = anySource().tiles;
686
676
  const source = ctx.map.getSource(props.id);
@@ -689,7 +679,7 @@ var Source = (props) => {
689
679
  });
690
680
  break;
691
681
  case "raster":
692
- createEffect3(() => {
682
+ createEffect2(() => {
693
683
  const src = lookup(anySource().url);
694
684
  const source = ctx.map.getSource(props.id);
695
685
  src.url ? source.setUrl(src.url) : source.setTiles(src.tiles);
@@ -712,12 +702,12 @@ var Source = (props) => {
712
702
  // src/components/Layer/index.tsx
713
703
  import {
714
704
  onCleanup as onCleanup3,
715
- createEffect as createEffect4,
705
+ createEffect as createEffect3,
716
706
  createMemo,
717
707
  createUniqueId as createUniqueId2
718
708
  } from "solid-js";
719
709
 
720
- // src/styles.ts
710
+ // src/components/Layer/styles.ts
721
711
  var baseStyle = [
722
712
  "id",
723
713
  "type",
@@ -781,7 +771,7 @@ var layoutStyles = [
781
771
  "text-writing-mode"
782
772
  ];
783
773
 
784
- // src/colors.ts
774
+ // src/components/Layer/colors.ts
785
775
  var probe;
786
776
  var toRgbString = (cssColor) => {
787
777
  probe ??= document.body.appendChild(document.createElement("div"));
@@ -814,37 +804,8 @@ var resolveColor = (value) => {
814
804
  }
815
805
  return value;
816
806
  };
817
- var toRgbaComponents = (value) => {
818
- const rgb = toRgbString(resolveColor(value)) ?? value;
819
- const match = rgb.match(/rgba?\(([^)]+)\)/i);
820
- if (!match) return [0, 0, 0, 1];
821
- const [r, g, b, a = 1] = match[1].split(",").map(Number);
822
- return [r, g, b, a];
823
- };
824
807
 
825
808
  // src/components/Layer/index.tsx
826
- var PULSE_DEFAULTS = {
827
- property: "icon-halo-width",
828
- from: 0,
829
- to: 8,
830
- duration: 1500,
831
- waveform: "out"
832
- };
833
- var PULSE_RAMP_FRACTION = 0.75;
834
- var easeOutQuad = (t) => 1 - (1 - t) * (1 - t);
835
- var pulseShape = (elapsed, duration, waveform) => {
836
- const phase = elapsed % duration / duration;
837
- if (waveform === "in-out") return (1 - Math.cos(phase * Math.PI * 2)) / 2;
838
- const ramp = Math.min(phase / PULSE_RAMP_FRACTION, 1);
839
- return easeOutQuad(ramp);
840
- };
841
- var lerpColor = (from, to, t) => {
842
- const r = Math.round(from[0] + (to[0] - from[0]) * t);
843
- const g = Math.round(from[1] + (to[1] - from[1]) * t);
844
- const b = Math.round(from[2] + (to[2] - from[2]) * t);
845
- const a = from[3] + (to[3] - from[3]) * t;
846
- return `rgba(${r}, ${g}, ${b}, ${a})`;
847
- };
848
809
  var diff = (newProps = {}, prevProps = {}) => {
849
810
  const keys = /* @__PURE__ */ new Set([...Object.keys(newProps), ...Object.keys(prevProps)]);
850
811
  return [...keys].reduce((acc, key) => {
@@ -856,9 +817,16 @@ var diff = (newProps = {}, prevProps = {}) => {
856
817
  }, []);
857
818
  };
858
819
  var newKey = (key, type) => (key.startsWith(type) || key.startsWith("icon") || key.startsWith("text") ? "" : type + "-") + key.replace(/[A-Z]/g, (s) => "-" + s.toLowerCase());
859
- var resolveColor2 = (key, value) => key.endsWith("color") && typeof value === "string" ? resolveColor(value) : value;
820
+ var misplacedTopLevelProps = ["slot", "filter", "visible", "beforeId", "beforeType"];
821
+ var resolveColor2 = (key, value) => {
822
+ if (!key.endsWith("color")) return value;
823
+ if (Array.isArray(value)) return value.map((v) => resolveColor2(key, v));
824
+ return typeof value === "string" ? resolveColor(value) : value;
825
+ };
860
826
  var constantRef = /^@(.+)$/;
861
827
  var resolveConstant = (key, value, constants, debug) => {
828
+ if (Array.isArray(value))
829
+ return value.map((v) => resolveConstant(key, v, constants, debug));
862
830
  if (typeof value !== "string") return value;
863
831
  const match = value.match(constantRef);
864
832
  if (!match) return value;
@@ -879,6 +847,10 @@ var updateStyle = (oldStyle, constants = {}, debug = () => {
879
847
  Object.entries(oldStyle).forEach(([key, value]) => {
880
848
  if (baseStyle.includes(key)) style[key] = value;
881
849
  else {
850
+ if (misplacedTopLevelProps.includes(key))
851
+ debug(
852
+ `"${key}" is a <Layer> prop, not a style property \u2014 belongs outside "style", not inside it. Treating it as a paint/layout property instead.`
853
+ );
882
854
  const nk = newKey(key, oldStyle.type);
883
855
  layoutStyles.includes(nk) ? layout[nk] = resolveConstant(nk, value, constants, debug) : paint[nk] = resolvePaint(nk, value);
884
856
  }
@@ -910,7 +882,7 @@ var Layer = (props) => {
910
882
  ...updateStyle(props.style, ctx.constants, debug),
911
883
  id: layerId,
912
884
  source: sourceId,
913
- // `slot` is Mapbox Standard-Style-only — MapLibre has no equivalent (see docs/dev-notes.md)
885
+ // `slot` is Mapbox Standard-Style-only — MapLibre has no equivalent (see .claude/dev-notes.md)
914
886
  ...ctx.isMapLibre ? {} : { slot: props.slot || "" },
915
887
  metadata: {
916
888
  smg: { beforeType: props.beforeType, beforeId: props.beforeId }
@@ -925,13 +897,13 @@ var Layer = (props) => {
925
897
  if (props[item]) {
926
898
  const event = item.slice(2).toLowerCase();
927
899
  ctx.map.on(event, layerId, (evt) => {
928
- evt.clickOnLayer = true;
900
+ if (event === "click") evt.clickOnLayer = true;
929
901
  props[item](evt);
930
902
  ctx.map.debugEvents && debug(`Layer '${event}' event on '${layerId}':`, evt);
931
903
  });
932
904
  }
933
905
  });
934
- createEffect4((prev) => {
906
+ createEffect3((prev) => {
935
907
  ctx.themeVersion;
936
908
  const style = updateStyle(props.style, ctx.constants, debug);
937
909
  if (style === prev) return;
@@ -950,7 +922,7 @@ var Layer = (props) => {
950
922
  debug("Update Layer Style:", layerId);
951
923
  return style;
952
924
  }, updateStyle(props.style, ctx.constants, debug));
953
- createEffect4((prev) => {
925
+ createEffect3((prev) => {
954
926
  if (props.visible === prev) return;
955
927
  ctx.map.setLayoutProperty(
956
928
  layerId,
@@ -961,19 +933,20 @@ var Layer = (props) => {
961
933
  debug(`Update Visibility (${layerId}):`, props.visible.toString());
962
934
  return props.visible;
963
935
  }, props.visible);
964
- createEffect4((prev) => {
936
+ createEffect3((prev) => {
965
937
  if (getBeforeId() === prev) return prev;
966
938
  ctx.map.moveLayer(layerId, getBeforeId());
967
939
  debug(`Update Layer Z-Index (${layerId}):`, getBeforeId());
968
940
  return getBeforeId();
969
941
  }, getBeforeId());
970
- createEffect4(async () => {
971
- if (!props.filter) return;
972
- !ctx.map.isStyleLoaded() && await ctx.map.once("styledata");
973
- ctx.map.setFilter(layerId, props.filter);
942
+ createEffect3((prev) => {
943
+ if (props.filter === prev) return prev;
944
+ if (prev === void 0 && !props.filter) return prev;
945
+ ctx.map.setFilter(layerId, props.filter ?? null);
974
946
  debug(`Update Filter (${layerId}):`, props.filter);
975
- });
976
- createEffect4(async () => {
947
+ return props.filter;
948
+ }, void 0);
949
+ createEffect3(async () => {
977
950
  if (!props.featureState || props.featureState.id === null) return;
978
951
  !ctx.map.isStyleLoaded() && await ctx.map.once("styledata");
979
952
  ctx.map.removeFeatureState({
@@ -989,43 +962,27 @@ var Layer = (props) => {
989
962
  props.featureState.state
990
963
  );
991
964
  });
992
- createEffect4(() => {
965
+ createEffect3(() => {
993
966
  if (!props.pulse) return;
994
- const configs = props.pulse === true ? [{}] : Array.isArray(props.pulse) ? props.pulse : [props.pulse];
995
- const resolved = configs.map((config) => {
996
- const { property, from, to, duration, waveform } = {
997
- ...PULSE_DEFAULTS,
998
- ...config
999
- };
1000
- const isColor = typeof from === "string" || typeof to === "string";
1001
- const [a, b] = waveform === "in" ? [to, from] : [from, to];
1002
- return {
1003
- property,
1004
- duration,
1005
- waveform,
1006
- isColor,
1007
- fromNum: isColor ? 0 : a,
1008
- toNum: isColor ? 0 : b,
1009
- fromRgba: isColor ? toRgbaComponents(a) : null,
1010
- toRgba: isColor ? toRgbaComponents(b) : null
967
+ const configs = Array.isArray(props.pulse) ? props.pulse : [props.pulse];
968
+ const timers = configs.map((config) => {
969
+ const { property, duration = 1500, holdFraction = 0.25 } = config;
970
+ const from = resolveColor2(property, config.from);
971
+ const to = resolveColor2(property, config.to);
972
+ const rampMs = duration * (1 - holdFraction);
973
+ const beat = () => {
974
+ ctx.map.setPaintProperty(layerId, `${property}-transition`, { duration: 0, delay: 0 }, { validate: false });
975
+ ctx.map.setPaintProperty(layerId, property, from, { validate: false });
976
+ requestAnimationFrame(() => {
977
+ ctx.map.setPaintProperty(layerId, `${property}-transition`, { duration: rampMs, delay: 0 }, { validate: false });
978
+ ctx.map.setPaintProperty(layerId, property, to, { validate: false });
979
+ });
1011
980
  };
981
+ beat();
982
+ return window.setInterval(beat, duration);
1012
983
  });
1013
- const start = performance.now();
1014
- let frameId;
1015
- const loop = (now) => {
1016
- const elapsed = now - start;
1017
- resolved.forEach((cfg) => {
1018
- const t = pulseShape(elapsed, cfg.duration, cfg.waveform);
1019
- const value = cfg.isColor ? lerpColor(cfg.fromRgba, cfg.toRgba, t) : cfg.fromNum + (cfg.toNum - cfg.fromNum) * t;
1020
- ctx.map.setPaintProperty(layerId, cfg.property, value, {
1021
- validate: false
1022
- });
1023
- });
1024
- frameId = window.requestAnimationFrame(loop);
1025
- };
1026
- frameId = window.requestAnimationFrame(loop);
1027
984
  debug(`Start Pulse (${layerId}):`, props.pulse);
1028
- onCleanup3(() => window.cancelAnimationFrame(frameId));
985
+ onCleanup3(() => timers.forEach((timer) => window.clearInterval(timer)));
1029
986
  });
1030
987
  onCleanup3(() => ctx.map?.getLayer(layerId) && ctx.map?.removeLayer(layerId));
1031
988
  return props.children;
@@ -1037,11 +994,11 @@ import {
1037
994
  createUniqueId as createUniqueId3,
1038
995
  createSignal as createSignal2,
1039
996
  onMount as onMount2,
1040
- createContext as createContext3,
1041
- useContext as useContext3
997
+ createContext as createContext2,
998
+ useContext as useContext2
1042
999
  } from "solid-js";
1043
- var LayerContext = createContext3();
1044
- var useScene = () => useContext3(LayerContext);
1000
+ var LayerContext = createContext2();
1001
+ var useScene = () => useContext2(LayerContext);
1045
1002
  var Layer3D = (props) => {
1046
1003
  const [ctx] = useMapContext();
1047
1004
  const [scene, setScene] = createSignal2(null);
@@ -1181,10 +1138,10 @@ var Layer3D = (props) => {
1181
1138
  };
1182
1139
 
1183
1140
  // src/components/Atmosphere/index.tsx
1184
- import { onCleanup as onCleanup5, createEffect as createEffect5 } from "solid-js";
1141
+ import { onCleanup as onCleanup5, createEffect as createEffect4 } from "solid-js";
1185
1142
  var Atmosphere = (props) => {
1186
1143
  const [ctx] = useMapContext();
1187
- createEffect5(() => {
1144
+ createEffect4(() => {
1188
1145
  if (ctx.isMapLibre) ctx.map.setSky?.(props.style || {});
1189
1146
  else ctx.map.setFog(props.style || {});
1190
1147
  });
@@ -1200,7 +1157,7 @@ var Atmosphere = (props) => {
1200
1157
 
1201
1158
  // src/components/Terrain/index.tsx
1202
1159
  import {
1203
- createEffect as createEffect6,
1160
+ createEffect as createEffect5,
1204
1161
  createUniqueId as createUniqueId4,
1205
1162
  onCleanup as onCleanup6
1206
1163
  } from "solid-js";
@@ -1217,7 +1174,7 @@ var Terrain = (props) => {
1217
1174
  });
1218
1175
  ctx.map.sourceIdList.push(sourceId);
1219
1176
  }
1220
- createEffect6(() => {
1177
+ createEffect5(() => {
1221
1178
  ctx.map.setTerrain({
1222
1179
  exaggeration: props.exaggeration || 1,
1223
1180
  source: props?.source || sourceId
@@ -1228,13 +1185,13 @@ var Terrain = (props) => {
1228
1185
  };
1229
1186
 
1230
1187
  // src/components/Control/index.tsx
1231
- import { createSignal as createSignal3, createEffect as createEffect8, splitProps, untrack } from "solid-js";
1188
+ import { createSignal as createSignal3, createEffect as createEffect7, splitProps, untrack } from "solid-js";
1232
1189
 
1233
1190
  // src/lib/createMapControl.ts
1234
- import { createEffect as createEffect7, onCleanup as onCleanup7 } from "solid-js";
1191
+ import { createEffect as createEffect6, onCleanup as onCleanup7 } from "solid-js";
1235
1192
  var useControlPosition = (control, position) => {
1236
1193
  const [ctx] = useMapContext();
1237
- createEffect7(() => {
1194
+ createEffect6(() => {
1238
1195
  const c = control();
1239
1196
  const pos = position?.();
1240
1197
  if (!c) return;
@@ -1261,7 +1218,7 @@ var Control = (props) => {
1261
1218
  ["logo", ctx.mapLib.LogoControl],
1262
1219
  ["terrain", ctx.mapLib.TerrainControl]
1263
1220
  ]);
1264
- createEffect8(() => {
1221
+ createEffect7(() => {
1265
1222
  untrack(
1266
1223
  () => control() && ctx.map.hasControl(control()) && ctx.map.removeControl(control())
1267
1224
  );
@@ -1274,7 +1231,7 @@ var Control = (props) => {
1274
1231
  };
1275
1232
 
1276
1233
  // src/components/Marker/index.tsx
1277
- import { onCleanup as onCleanup8, createEffect as createEffect9, splitProps as splitProps2 } from "solid-js";
1234
+ import { onCleanup as onCleanup8, createEffect as createEffect8, splitProps as splitProps2 } from "solid-js";
1278
1235
  var Marker = (props) => {
1279
1236
  if (!props.lngLat) throw new Error("Marker - lngLat is required");
1280
1237
  const [update, create_popup, create_marker] = splitProps2(
@@ -1286,7 +1243,7 @@ var Marker = (props) => {
1286
1243
  let marker = null;
1287
1244
  let popup = null;
1288
1245
  const LNGLAT = update.lngLat;
1289
- createEffect9(() => {
1246
+ createEffect8(() => {
1290
1247
  if (!ctx.map) return;
1291
1248
  popup?.remove();
1292
1249
  popup = new ctx.mapLib.Popup({
@@ -1294,31 +1251,31 @@ var Marker = (props) => {
1294
1251
  focusAfterOpen: false,
1295
1252
  ...create_popup.popup
1296
1253
  }).on("open", () => create_popup.onOpen?.()).on("close", () => create_popup.onClose?.());
1297
- createEffect9(() => {
1254
+ createEffect8(() => {
1298
1255
  if (update.children === void 0) return;
1299
1256
  typeof update.children === "string" ? popup?.setHTML(update.children) : popup?.setDOMContent(update.children);
1300
1257
  marker?.setPopup(popup);
1301
1258
  });
1302
- createEffect9(
1259
+ createEffect8(
1303
1260
  () => update.showPopup !== popup?.isOpen() && marker?.togglePopup()
1304
1261
  );
1305
1262
  });
1306
- createEffect9(() => {
1263
+ createEffect8(() => {
1307
1264
  if (!ctx.map) return;
1308
1265
  marker?.remove();
1309
1266
  marker = new ctx.mapLib.Marker(create_marker.options).on("dragstart", () => create_marker.onDragStart?.()).on("dragend", () => create_marker.onDragEnd?.()).on("drag", () => create_marker.onDrag?.(marker?.getLngLat().toArray())).setPopup(popup).setLngLat(LNGLAT).addTo(ctx.map);
1310
- createEffect9(
1267
+ createEffect8(
1311
1268
  () => update.showPopup !== popup?.isOpen() && marker?.togglePopup()
1312
1269
  );
1313
1270
  });
1314
- createEffect9(() => marker?.setLngLat(update.lngLat));
1315
- createEffect9(() => marker?.setDraggable(update.draggable));
1271
+ createEffect8(() => marker?.setLngLat(update.lngLat));
1272
+ createEffect8(() => marker?.setDraggable(update.draggable));
1316
1273
  onCleanup8(() => marker?.remove());
1317
1274
  return null;
1318
1275
  };
1319
1276
 
1320
1277
  // src/components/Popup/index.tsx
1321
- import { onCleanup as onCleanup9, createEffect as createEffect10, splitProps as splitProps3 } from "solid-js";
1278
+ import { onCleanup as onCleanup9, createEffect as createEffect9, splitProps as splitProps3 } from "solid-js";
1322
1279
  var Popup = (props) => {
1323
1280
  if (!props.trackPointer && !props.lngLat)
1324
1281
  throw new Error("Popup - lngLat or trackPointer is required");
@@ -1329,7 +1286,7 @@ var Popup = (props) => {
1329
1286
  ]);
1330
1287
  const [ctx] = useMapContext();
1331
1288
  let popup;
1332
- createEffect10(() => {
1289
+ createEffect9(() => {
1333
1290
  if (!ctx.map) return;
1334
1291
  popup?.remove();
1335
1292
  popup = new ctx.mapLib.Popup({
@@ -1337,10 +1294,10 @@ var Popup = (props) => {
1337
1294
  focusAfterOpen: false,
1338
1295
  ...create.options
1339
1296
  }).on("open", () => create.onOpen?.()).on("close", () => create.onClose?.()).addTo(ctx.map);
1340
- createEffect10(
1297
+ createEffect9(
1341
1298
  () => update.trackPointer ? popup.trackPointer() : popup.setLngLat(update.lngLat)
1342
1299
  );
1343
- createEffect10(
1300
+ createEffect9(
1344
1301
  () => typeof update.children === "string" ? popup.setHTML(update.children) : popup.setDOMContent(update.children)
1345
1302
  );
1346
1303
  });
@@ -1352,7 +1309,7 @@ var Popup = (props) => {
1352
1309
  import {
1353
1310
  onCleanup as onCleanup10,
1354
1311
  createSignal as createSignal4,
1355
- createEffect as createEffect11,
1312
+ createEffect as createEffect10,
1356
1313
  untrack as untrack2
1357
1314
  } from "solid-js";
1358
1315
 
@@ -1364,12 +1321,12 @@ for (let i = 0; i < 256; i++) {
1364
1321
  ALPHA_TABLE[i] = d * Math.abs(d);
1365
1322
  }
1366
1323
  ALPHA_TABLE[255] = -INF;
1367
- function edt1d(grid, offset, stride, length3, f, v, z) {
1324
+ function edt1d(grid, offset, stride, length2, f, v, z) {
1368
1325
  v[0] = 0;
1369
1326
  z[0] = -INF;
1370
1327
  z[1] = INF;
1371
1328
  f[0] = grid[offset];
1372
- for (let q = 1, k = 0, s = 0; q < length3; q++) {
1329
+ for (let q = 1, k = 0, s = 0; q < length2; q++) {
1373
1330
  f[q] = grid[offset + q * stride];
1374
1331
  const q2 = q * q;
1375
1332
  do {
@@ -1381,7 +1338,7 @@ function edt1d(grid, offset, stride, length3, f, v, z) {
1381
1338
  z[k] = s;
1382
1339
  z[k + 1] = INF;
1383
1340
  }
1384
- for (let q = 0, k = 0; q < length3; q++) {
1341
+ for (let q = 0, k = 0; q < length2; q++) {
1385
1342
  while (z[k + 1] < q) k++;
1386
1343
  const r = v[k];
1387
1344
  const qr = q - r;
@@ -1461,34 +1418,51 @@ var PATTERN = {
1461
1418
  wave: { size: 20, path: "M0 5Q5 0 10 5T20 5M0 15Q5 10 10 15T20 15" }
1462
1419
  };
1463
1420
  var patternList = Object.keys(PATTERN);
1464
- var svg = (body) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64">${body}</svg>`;
1421
+ var svg = (path) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" stroke-linecap="round" stroke-linejoin="round">
1422
+ <path d="${path}" fill="#000" stroke="#000" stroke-width="3"/>
1423
+ </svg>`;
1465
1424
  var SYMBOL = {
1466
- square: svg('<rect x="8" y="8" width="48" height="48" fill="#000"/>'),
1467
- circle: svg('<circle cx="32" cy="32" r="28" fill="#000"/>'),
1468
- triangle: svg('<polygon points="32,6 60,56 4,56" fill="#000"/>'),
1469
- diamond: svg('<polygon points="32,4 60,32 32,60 4,32" fill="#000"/>'),
1470
- pentagon: svg('<polygon points="32,4 59,23 48,55 16,55 5,23" fill="#000"/>'),
1471
- hexagon: svg('<polygon points="32,4 56,18 56,46 32,60 8,46 8,18" fill="#000"/>'),
1425
+ square: svg("M3,3 L21,3 L21,21 L3,21 Z"),
1426
+ // Two semicircular arcs sharing one center/radius, traced in the same direction both times
1427
+ // (the standard "circle via two arcs" trick). The requested `1,1` radius is far smaller than
1428
+ // half the 16-unit chord between the two points, so per the SVG spec it's scaled up to the
1429
+ // minimum radius that can still connect them (8, i.e. exactly a semicircle each) — the circle
1430
+ // ends up centered on the chord's midpoint (12,11), not on the literal "1".
1431
+ circle: svg("M 12 4 A 1 1 0 0 0 12 20 A 1 1 0 0 0 12 4 Z"),
1432
+ triangle: svg("M 12 2 L 22 19 H 2 Z"),
1433
+ diamond: svg("M 12 1 L 19 12 L 12 23 L 5 12 Z"),
1434
+ pentagon: svg("M12,3 L21,9 L17,19 L7,19 L3,9 Z"),
1435
+ hexagon: svg("M12,3 L20,7.5 L20,16.5 L12,21 L4,16.5 L4,7.5 Z"),
1472
1436
  // A square with corners cut at 2/7 of its side, the standard construction for a regular
1473
1437
  // octagon (stop-sign proportions) without resorting to trig.
1474
- octagon: svg(
1475
- '<polygon points="20,4 44,4 60,20 60,44 44,60 20,60 4,44 4,20" fill="#000"/>'
1476
- ),
1477
- cross: svg(
1478
- '<polygon points="20,4 44,4 44,20 60,20 60,44 44,44 44,60 20,60 20,44 4,44 4,20 20,20" fill="#000"/>'
1479
- ),
1438
+ octagon: svg("M 8 3 Q 12 3.3 16 3 Q 18.3 5.7 21 8 Q 20.7 12 21 16 Q 18.3 18.3 16 21 Q 12 20.7 8 21 Q 5.8 18.2 3 16 Q 3.3 12 3 8 Q 5.7 5.7 8 3 Z"),
1439
+ cross: svg("M 10.5 3 h 3 v 7.5 h 7.5 v 3 h -7.5 v 7.5 h -3 v -7.5 h -7.5 v -3 h 7.5 Z"),
1480
1440
  // The same 12-point "+" as `cross` above, rotated 45° about the center.
1481
- x: svg(
1482
- '<polygon points="43,4 60,21 49,32 60,43 43,60 32,49 21,60 4,43 15,32 4,21 21,4 32,15" fill="#000"/>'
1483
- ),
1484
- // A regular 5-pointed star: outer vertices every 72° (radius 30) alternating with inner
1485
- // vertices every 72° offset by 36° (radius ~11.5, the usual ratio for a balanced star).
1486
- star: svg(
1487
- '<polygon points="32,2 39,23 61,23 43,36 50,56 32,44 14,56 21,36 4,23 25,23" fill="#000"/>'
1488
- )
1441
+ x: svg("M 18 4 L 20 6 L 14 12 L 20 18 L 18 20 L 12 14 L 6 20 L 4 18 L 10 12 L 4 6 L 6 4 L 12 10 Z"),
1442
+ // A regular 5-pointed star: outer vertices every 72° alternating with inner vertices every
1443
+ // 72° offset by 36° (inner radius ~40% of the outer radius, the usual ratio for a balanced star).
1444
+ star: svg("M12,3 L14,9 L20.5,9 L15.5,13 L17.5,19.5 L12,15.5 L6.5,19.5 L8.5,13 L3.5,9 L10,9 Z"),
1445
+ // Two circular lobes (centers 8.5,8 / 15.5,8, radius 4.5 apart enough to overlap) joined by
1446
+ // straight tangent lines down to a bottom point. The notch between the lobes is the two
1447
+ // circles' actual intersection point (computed, not eyeballed), so both arcs land on it
1448
+ // exactly with no seam.
1449
+ heart: svg("M 12 21 L 3 11 A 4.5 4.5 0 1 1 11 8 L 13 8 A 4.5 4.5 0 1 1 21 11 Z"),
1450
+ // A map-pin/teardrop: a circle (center 12,10, r6) with two lines tangent to it converging on a
1451
+ // point below, so the straight edges meet the round top without a kink — the tangent points
1452
+ // and angles come from `acos(r / distance-to-point)`, not eyeballing.
1453
+ pin: svg("M 12 21 L 7 11 A 6 6 0 0 1 12 2 A 6 6 0 0 1 17 11 Z"),
1454
+ // The same tangent-circle construction as `pin`, just with the circle bigger relative to how
1455
+ // far below it the point sits (r6/d11 there vs r7.5/d10.5 here) — a shorter, wider point on a
1456
+ // rounder body: "a circle with one pointy edge" rather than a full elongated marker.
1457
+ drop: svg("M 4 21 V 12 A 7.5 7.5 0 0 1 12 4 A 7.5 7.5 0 0 1 13 21 Z"),
1458
+ // A thick chevron/bracket built as a filled ribbon, not a stroked open line: the outer and
1459
+ // inner edges of a constant-width "V", offset perpendicular to each arm and mitered where the
1460
+ // arms meet (both at the outer point and the inner notch). Has to be a closed silhouette like
1461
+ // every other symbol here, since `sdf` only encodes a filled alpha shape, not a stroke.
1462
+ chevron: svg("M 8 4 L 14 12 L 8 20 H 5 L 11 12 L 5 4 Z")
1489
1463
  };
1490
1464
  var symbolList = Object.keys(SYMBOL);
1491
- var wrapSymbolPath = (d) => svg(`<path d="${d}" fill="#000"/>`);
1465
+ var wrapSymbolPath = (d) => svg(d);
1492
1466
 
1493
1467
  // src/components/Image/index.tsx
1494
1468
  var MGL_Image = (props) => {
@@ -1509,7 +1483,7 @@ var MGL_Image = (props) => {
1509
1483
  ctx.map?.hasImage(props.id) && ctx.map?.removeImage(props.id);
1510
1484
  debug("Remove Image:", props.id);
1511
1485
  });
1512
- createEffect11(() => {
1486
+ createEffect10(() => {
1513
1487
  if (!props.id) throw new Error("Image - ID is required");
1514
1488
  if (!props.source && !props.pattern && !props.symbol)
1515
1489
  throw new Error("Image - Image, Pattern or Symbol is required");
@@ -1557,10 +1531,11 @@ var MGL_Image = (props) => {
1557
1531
  const img = new Image();
1558
1532
  img.crossOrigin = "Anonymous";
1559
1533
  img.onload = () => {
1560
- const floorScale = Math.max(1, 50 / Math.min(img.width, img.height));
1534
+ const minAxis = Math.min(img.width, img.height);
1535
+ const floorScale = minAxis > 0 ? Math.max(1, 50 / minAxis) : 1;
1561
1536
  const pixelRatio = props.options?.pixelRatio ?? Math.max(1, Math.round(window.devicePixelRatio || 1));
1562
1537
  const scale = floorScale * pixelRatio;
1563
- const padding = sdfOpts ? sdfPadding(sdfOpts) * pixelRatio : 0;
1538
+ const padding = sdfOpts ? sdfPadding(sdfOpts) * scale : 0;
1564
1539
  const drawWidth = Math.round(img.width * scale);
1565
1540
  const drawHeight = Math.round(img.height * scale);
1566
1541
  const canvas = document.createElement("canvas");
@@ -1572,7 +1547,7 @@ var MGL_Image = (props) => {
1572
1547
  const imageData2 = ctx2.getImageData(0, 0, canvas.width, canvas.height);
1573
1548
  return callback(
1574
1549
  sdfOpts ? toSDF(imageData2, sdfOpts) : imageData2,
1575
- pixelRatio
1550
+ scale
1576
1551
  );
1577
1552
  };
1578
1553
  img.onerror = (event) => console.error(`[MapGL] Image "${props.id}" failed to load:`, event);
@@ -1625,7 +1600,7 @@ var MGL_Image = (props) => {
1625
1600
  };
1626
1601
 
1627
1602
  // src/components/Camera/index.tsx
1628
- import { createEffect as createEffect12, onCleanup as onCleanup11, createSignal as createSignal5 } from "solid-js";
1603
+ import { createEffect as createEffect11, onCleanup as onCleanup11, createSignal as createSignal5 } from "solid-js";
1629
1604
  var lerp = (a, b, t) => a.map((_, idx) => (1 - t) * a[idx] + t * b[idx]);
1630
1605
  var slerp = (a, b, t) => {
1631
1606
  const dotProduct = a.map((_, idx) => a[idx] * b[idx]).reduce((m, n) => m + n);
@@ -1672,7 +1647,7 @@ var Camera = (props) => {
1672
1647
  isReverse = !isReverse;
1673
1648
  animationTime = isReverse ? animationTime - 1e-3 : animationTime + 1e-3;
1674
1649
  };
1675
- createEffect12(() => {
1650
+ createEffect11(() => {
1676
1651
  props.translate && window.requestAnimationFrame(frame);
1677
1652
  });
1678
1653
  const options = { duration: 1e3, easing: (n) => n };
@@ -1707,7 +1682,7 @@ var Camera = (props) => {
1707
1682
  const onEnd = () => props.rotateGlobe ? rotateGlobe() : rotateViewport();
1708
1683
  ctx.map.on("moveend", onEnd).on("dragend", onEnd);
1709
1684
  let originalCenter;
1710
- createEffect12(() => {
1685
+ createEffect11(() => {
1711
1686
  if (props.rotateGlobe == void 0) return;
1712
1687
  if (props.rotateGlobe) {
1713
1688
  originalCenter = ctx.map.getCenter();
@@ -1716,7 +1691,7 @@ var Camera = (props) => {
1716
1691
  props.resetWhenStopped ? ctx.map.stop().easeTo({ center: originalCenter }) : ctx.map.stop();
1717
1692
  }
1718
1693
  });
1719
- createEffect12(() => {
1694
+ createEffect11(() => {
1720
1695
  if (props.rotateViewport == void 0) return;
1721
1696
  props.rotateViewport ? rotateViewport() : props.resetWhenStopped ? ctx.map.stop().resetNorthPitch() : ctx.map.stop();
1722
1697
  });
@@ -1725,10 +1700,10 @@ var Camera = (props) => {
1725
1700
  };
1726
1701
 
1727
1702
  // src/components/Light/index.tsx
1728
- import { onCleanup as onCleanup12, createEffect as createEffect13 } from "solid-js";
1703
+ import { onCleanup as onCleanup12, createEffect as createEffect12 } from "solid-js";
1729
1704
  var Light = (props) => {
1730
1705
  const [ctx] = useMapContext();
1731
- createEffect13(() => ctx.map.setLight(props.style || {}));
1706
+ createEffect12(() => ctx.map.setLight(props.style || {}));
1732
1707
  onCleanup12(() => ctx.map?.setLight(null));
1733
1708
  return null;
1734
1709
  };
@@ -1764,11 +1739,105 @@ MultiPointMode.toDisplayFeatures = function(state, geojson, display) {
1764
1739
  };
1765
1740
  var multi_point_default = MultiPointMode;
1766
1741
 
1742
+ // src/components/Draw/modes/geo.ts
1743
+ var EARTH_RADIUS_KM = 6371.0088;
1744
+ var KM_PER_MILE = 1.609344;
1745
+ var EARTH_RADIUS_M = 6378137;
1746
+ function toRadians(deg) {
1747
+ return deg * Math.PI / 180;
1748
+ }
1749
+ function toDegrees(rad) {
1750
+ return rad * 180 / Math.PI;
1751
+ }
1752
+ function distance(from, to) {
1753
+ const dLat = toRadians(to[1] - from[1]);
1754
+ const dLng = toRadians(to[0] - from[0]);
1755
+ const lat1 = toRadians(from[1]);
1756
+ const lat2 = toRadians(to[1]);
1757
+ const a = Math.sin(dLat / 2) ** 2 + Math.cos(lat1) * Math.cos(lat2) * Math.sin(dLng / 2) ** 2;
1758
+ return EARTH_RADIUS_KM * 2 * Math.asin(Math.sqrt(a));
1759
+ }
1760
+ function length(coordinates, units = "kilometers") {
1761
+ let total = 0;
1762
+ for (let i = 1; i < coordinates.length; i++) {
1763
+ total += distance(coordinates[i - 1], coordinates[i]);
1764
+ }
1765
+ return units === "miles" ? total / KM_PER_MILE : total;
1766
+ }
1767
+ function midpoint(from, to) {
1768
+ const lat1 = toRadians(from[1]);
1769
+ const lon1 = toRadians(from[0]);
1770
+ const lat2 = toRadians(to[1]);
1771
+ const dLon = toRadians(to[0] - from[0]);
1772
+ const bx = Math.cos(lat2) * Math.cos(dLon);
1773
+ const by = Math.cos(lat2) * Math.sin(dLon);
1774
+ const lat3 = Math.atan2(
1775
+ Math.sin(lat1) + Math.sin(lat2),
1776
+ Math.sqrt((Math.cos(lat1) + bx) ** 2 + by ** 2)
1777
+ );
1778
+ const lon3 = lon1 + Math.atan2(by, Math.cos(lat1) + bx);
1779
+ return [toDegrees(lon3), toDegrees(lat3)];
1780
+ }
1781
+ function ringArea(ring) {
1782
+ const n = ring.length;
1783
+ if (n <= 2) return 0;
1784
+ let total = 0;
1785
+ for (let i = 0; i < n; i++) {
1786
+ let lower;
1787
+ let middle;
1788
+ let upper;
1789
+ if (i === n - 2) {
1790
+ lower = n - 2;
1791
+ middle = n - 1;
1792
+ upper = 0;
1793
+ } else if (i === n - 1) {
1794
+ lower = n - 1;
1795
+ middle = 0;
1796
+ upper = 1;
1797
+ } else {
1798
+ lower = i;
1799
+ middle = i + 1;
1800
+ upper = i + 2;
1801
+ }
1802
+ total += (toRadians(ring[upper][0]) - toRadians(ring[lower][0])) * Math.sin(toRadians(ring[middle][1]));
1803
+ }
1804
+ return total * EARTH_RADIUS_M * EARTH_RADIUS_M / 2;
1805
+ }
1806
+ function area(rings) {
1807
+ return rings.reduce((total, ring, i) => {
1808
+ const ringTotal = Math.abs(ringArea(ring));
1809
+ return i === 0 ? total + ringTotal : total - ringTotal;
1810
+ }, 0);
1811
+ }
1812
+ function centerOfMass(rings) {
1813
+ const ring = rings[0];
1814
+ let meanX = 0;
1815
+ let meanY = 0;
1816
+ for (const [x, y] of ring) {
1817
+ meanX += x;
1818
+ meanY += y;
1819
+ }
1820
+ meanX /= ring.length;
1821
+ meanY /= ring.length;
1822
+ let xSum = 0;
1823
+ let ySum = 0;
1824
+ let areaSum = 0;
1825
+ for (let i = 0; i < ring.length - 1; i++) {
1826
+ const x1 = ring[i][0] - meanX;
1827
+ const y1 = ring[i][1] - meanY;
1828
+ const x2 = ring[i + 1][0] - meanX;
1829
+ const y2 = ring[i + 1][1] - meanY;
1830
+ const cross = x1 * y2 - x2 * y1;
1831
+ xSum += (x1 + x2) * cross;
1832
+ ySum += (y1 + y2) * cross;
1833
+ areaSum += cross;
1834
+ }
1835
+ if (areaSum === 0) return [meanX, meanY];
1836
+ const factor = 1 / (3 * areaSum);
1837
+ return [meanX + xSum * factor, meanY + ySum * factor];
1838
+ }
1839
+
1767
1840
  // src/components/Draw/modes/measurements.ts
1768
- import length from "@turf/length";
1769
- import area from "@turf/area";
1770
- import midpoint from "@turf/midpoint";
1771
- import { centerOfMass } from "@turf/center-of-mass";
1772
1841
  var getCoords = (coords) => {
1773
1842
  return new Intl.NumberFormat(void 0, {
1774
1843
  maximumFractionDigits: 5
@@ -1778,17 +1847,8 @@ var getCoords = (coords) => {
1778
1847
  };
1779
1848
  var getLength = (coordinates, meta) => {
1780
1849
  const lengthValue = length(
1781
- {
1782
- type: "Feature",
1783
- properties: {},
1784
- geometry: {
1785
- type: "LineString",
1786
- coordinates
1787
- }
1788
- },
1789
- {
1790
- units: window.navigator.language === "en-US" ? "miles" : "kilometers"
1791
- }
1850
+ coordinates,
1851
+ window.navigator.language === "en-US" ? "miles" : "kilometers"
1792
1852
  );
1793
1853
  const label = window.navigator.language === "en-US" ? new Intl.NumberFormat(void 0, {
1794
1854
  style: "unit",
@@ -1808,19 +1868,12 @@ var getLength = (coordinates, meta) => {
1808
1868
  },
1809
1869
  geometry: {
1810
1870
  type: "Point",
1811
- coordinates: midpoint(coordinates[0], coordinates[1]).geometry.coordinates
1871
+ coordinates: midpoint(coordinates[0], coordinates[1])
1812
1872
  }
1813
1873
  };
1814
1874
  };
1815
1875
  var getArea = (coordinates, meta) => {
1816
- const areaValue = area({
1817
- type: "Feature",
1818
- properties: {},
1819
- geometry: {
1820
- type: "Polygon",
1821
- coordinates
1822
- }
1823
- });
1876
+ const areaValue = area(coordinates);
1824
1877
  const areaLabel = window.navigator.language === "en-US" ? new Intl.NumberFormat(void 0, {
1825
1878
  style: "unit",
1826
1879
  maximumFractionDigits: 2,
@@ -1839,10 +1892,10 @@ var getArea = (coordinates, meta) => {
1839
1892
  value: areaLabel,
1840
1893
  ...meta
1841
1894
  },
1842
- geometry: centerOfMass({
1843
- type: "Polygon",
1844
- coordinates
1845
- }).geometry
1895
+ geometry: {
1896
+ type: "Point",
1897
+ coordinates: centerOfMass(coordinates)
1898
+ }
1846
1899
  };
1847
1900
  };
1848
1901
 
@@ -1936,7 +1989,6 @@ var polygon_default = (lib) => {
1936
1989
  };
1937
1990
 
1938
1991
  // src/components/Draw/modes/radius.ts
1939
- import length2 from "@turf/length";
1940
1992
  function createVertex(parentId, coordinates, path, selected) {
1941
1993
  return {
1942
1994
  type: "Feature",
@@ -2019,7 +2071,7 @@ var RadiusMode = (lib) => ({
2019
2071
  state.line.removeCoordinate("0");
2020
2072
  if (state.line.isValid()) {
2021
2073
  const lineGeoJson = state.line.toGeoJSON();
2022
- const radius = (length2(lineGeoJson) * 1e3).toFixed(1);
2074
+ const radius = (length(lineGeoJson.geometry.coordinates) * 1e3).toFixed(1);
2023
2075
  const center = lineGeoJson.geometry.coordinates[0];
2024
2076
  this.deleteFeature([state.line.id], { silent: true });
2025
2077
  const point = this.newFeature({
@@ -2059,7 +2111,7 @@ var RadiusMode = (lib) => ({
2059
2111
  display(
2060
2112
  createGeoJSONCircle(
2061
2113
  geojson.geometry.coordinates[0],
2062
- length2(geojson),
2114
+ length(geojson.geometry.coordinates),
2063
2115
  state.line.id
2064
2116
  )
2065
2117
  );
@@ -2685,7 +2737,7 @@ var Draw = (props) => {
2685
2737
  };
2686
2738
 
2687
2739
  // src/components/DeckOverlay/index.tsx
2688
- import { createEffect as createEffect14 } from "solid-js";
2740
+ import { createEffect as createEffect13 } from "solid-js";
2689
2741
  var DeckOverlay = (props) => {
2690
2742
  const [ctx] = useMapContext();
2691
2743
  let overlay;
@@ -2694,7 +2746,7 @@ var DeckOverlay = (props) => {
2694
2746
  return overlay;
2695
2747
  };
2696
2748
  useControlPosition(control);
2697
- createEffect14(() => overlay?.setProps(props.props || {}));
2749
+ createEffect13(() => overlay?.setProps(props.props || {}));
2698
2750
  return null;
2699
2751
  };
2700
2752
  export {