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.
- package/README.md +4 -4
- package/dist/chunk/BTR7SKE6.js +7 -0
- package/dist/chunk/N4NHJCAS.jsx +28 -0
- package/dist/{index.d.ts → index/index.d.ts} +51 -40
- package/dist/index/index.js +10 -0
- package/dist/{index.jsx → index/index.jsx} +273 -221
- package/dist/testing/index.d.ts +109 -0
- package/dist/testing/index.js +8 -0
- package/dist/testing/index.jsx +334 -0
- package/package.json +38 -22
- package/dist/index.js +0 -11
package/README.md
CHANGED
|
@@ -85,10 +85,10 @@ import MapGL, { Viewport, Source, Layer } from "solid-map-gl";
|
|
|
85
85
|
import 'mapbox-gl/dist/mapbox-gl.css'
|
|
86
86
|
|
|
87
87
|
const App: Component = () => {
|
|
88
|
-
const [viewport, setViewport] = createSignal({
|
|
88
|
+
const [viewport, setViewport] = createSignal<Viewport>({
|
|
89
89
|
center: [-122.45, 37.78],
|
|
90
90
|
zoom: 11,
|
|
91
|
-
}
|
|
91
|
+
});
|
|
92
92
|
|
|
93
93
|
return (
|
|
94
94
|
<MapGL
|
|
@@ -143,10 +143,10 @@ import * as maplibre from 'maplibre-gl'
|
|
|
143
143
|
import 'maplibre-gl/dist/maplibre-gl.css'
|
|
144
144
|
|
|
145
145
|
const App: Component = () => {
|
|
146
|
-
const [viewport, setViewport] = createSignal({
|
|
146
|
+
const [viewport, setViewport] = createSignal<Viewport>({
|
|
147
147
|
center: [-122.45, 37.78],
|
|
148
148
|
zoom: 11,
|
|
149
|
-
}
|
|
149
|
+
});
|
|
150
150
|
|
|
151
151
|
return (
|
|
152
152
|
<MapGL
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createComponent } from 'solid-js/web';
|
|
2
|
+
import { createContext, useContext, createEffect } from 'solid-js';
|
|
3
|
+
import { createStore } from 'solid-js/store';
|
|
4
|
+
|
|
5
|
+
var a={map:null,mapLib:null,isMapLibre:false,constants:{},themeVersion:0},o=createContext([a]),f=()=>useContext(o),h=e=>{let[r,t]=createStore({...a});return e.map&&t("map",e.map),e.mapLib&&t("mapLib",e.mapLib),t("isMapLibre",!!e.isMapLibre),t("constants",e.constants||{}),t("themeVersion",e.themeVersion||0),createEffect(()=>t("constants",e.constants||{})),createEffect(()=>t("themeVersion",e.themeVersion||0)),createComponent(o.Provider,{value:[r],get children(){return e.children}})};
|
|
6
|
+
|
|
7
|
+
export { f as a, h as b };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// src/components/MapProvider/index.tsx
|
|
2
|
+
import { createContext, useContext, createEffect } from "solid-js";
|
|
3
|
+
import { createStore } from "solid-js/store";
|
|
4
|
+
var defaultState = {
|
|
5
|
+
map: null,
|
|
6
|
+
mapLib: null,
|
|
7
|
+
isMapLibre: false,
|
|
8
|
+
constants: {},
|
|
9
|
+
themeVersion: 0
|
|
10
|
+
};
|
|
11
|
+
var MapContext = createContext([defaultState]);
|
|
12
|
+
var useMapContext = () => useContext(MapContext);
|
|
13
|
+
var MapProvider = (props) => {
|
|
14
|
+
const [state, setState] = createStore({ ...defaultState });
|
|
15
|
+
props.map && setState("map", props.map);
|
|
16
|
+
props.mapLib && setState("mapLib", props.mapLib);
|
|
17
|
+
setState("isMapLibre", !!props.isMapLibre);
|
|
18
|
+
setState("constants", props.constants || {});
|
|
19
|
+
setState("themeVersion", props.themeVersion || 0);
|
|
20
|
+
createEffect(() => setState("constants", props.constants || {}));
|
|
21
|
+
createEffect(() => setState("themeVersion", props.themeVersion || 0));
|
|
22
|
+
return <MapContext.Provider value={[state]}>{props.children}</MapContext.Provider>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
useMapContext,
|
|
27
|
+
MapProvider
|
|
28
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component, JSX, ParentComponent, VoidComponent } from 'solid-js';
|
|
2
|
-
import { MapMouseEvent, MapTouchEvent, MapWheelEvent, MapDataEvent, MapBoxZoomEvent, LngLatLike,
|
|
2
|
+
import { MapMouseEvent, MapTouchEvent, MapWheelEvent, MapDataEvent, MapBoxZoomEvent, LngLatLike, LngLatBoundsLike, PaddingOptions, MapboxOptions, StyleSpecification, SourceSpecification, CustomLayerInterface, FilterSpecification, FogSpecification, NavigationControlOptions, ScaleControlOptions, AttributionControlOptions, FullscreenControlOptions, GeolocateControlOptions, MarkerOptions, PopupOptions, StyleImageInterface, Map as Map$1, LightSpecification } from 'mapbox-gl';
|
|
3
3
|
|
|
4
4
|
/** Any object shaped enough like `mapboxgl.Map`/`maplibregl.Map` for the functions in this module —
|
|
5
5
|
* kept loose (not the real `mapboxgl.Map` type) so this file has no hard dependency on either
|
|
@@ -32,7 +32,11 @@ type SettleOptions = {
|
|
|
32
32
|
declare function settleAfterIdle(map: SettleableMap, options?: SettleOptions): Promise<void>;
|
|
33
33
|
/** Waits for the map's next 'idle' event, then `settleAfterIdle`. The convenience entry point for
|
|
34
34
|
* off-screen/headless capture: call your own `jumpTo`/`fitBounds`/`setData` first, then `await` this
|
|
35
|
-
* before reading the canvas.
|
|
35
|
+
* before reading the canvas. Calls `triggerRepaint()` itself before waiting — 'idle' only fires on
|
|
36
|
+
* the *transition into* idle, so a map that's already idle with nothing queued (e.g. capturing
|
|
37
|
+
* whatever's on screen with no preceding camera/data change) would otherwise never fire another one
|
|
38
|
+
* and this would hang forever. Redundant, and harmless, if the map isn't idle yet: mapbox-gl/
|
|
39
|
+
* maplibre-gl coalesce repeated `triggerRepaint()` calls into whatever frame is already pending. */
|
|
36
40
|
declare function waitForIdleAndSettle(map: SettleableMap, options?: SettleOptions): Promise<void>;
|
|
37
41
|
/** Zeros `raster-fade-duration` on every layer that supports it, so newly-loaded raster tiles
|
|
38
42
|
* appear at full opacity immediately instead of cross-fading in over mapbox-gl's default 300ms —
|
|
@@ -184,7 +188,7 @@ type Viewport = {
|
|
|
184
188
|
y: number;
|
|
185
189
|
};
|
|
186
190
|
center?: LngLatLike;
|
|
187
|
-
bounds?:
|
|
191
|
+
bounds?: LngLatBoundsLike;
|
|
188
192
|
zoom?: number;
|
|
189
193
|
pitch?: number;
|
|
190
194
|
bearing?: number;
|
|
@@ -204,10 +208,11 @@ type Props$b = {
|
|
|
204
208
|
};
|
|
205
209
|
/** Current Map View */
|
|
206
210
|
viewport?: Viewport;
|
|
207
|
-
/** Mapbox Options
|
|
211
|
+
/** Mapbox Options. `container` is always set internally (see setupMap below) and is omitted
|
|
212
|
+
* from this type since a consumer-supplied value would just be silently overridden.
|
|
208
213
|
* @see https://docs.mapbox.com/mapbox-gl-js/api/map/#map-parameters
|
|
209
214
|
*/
|
|
210
|
-
options?: MapboxOptions
|
|
215
|
+
options?: Omit<MapboxOptions, "container">;
|
|
211
216
|
/** Mapbox Standard / Standard Satellite style configuration — Mapbox-only, no-op on MapLibre.
|
|
212
217
|
* @see https://docs.mapbox.com/mapbox-gl-js/guides/styles/#configure-a-style
|
|
213
218
|
*/
|
|
@@ -293,13 +298,19 @@ type Props$b = {
|
|
|
293
298
|
* Default `true`. */
|
|
294
299
|
disableRasterFade?: boolean;
|
|
295
300
|
};
|
|
296
|
-
/** Called once, after the map loads, with a capturer for grabbing the canvas as an image —
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
301
|
+
/** Called once, after the map loads, with a capturer for grabbing the canvas as an image — works
|
|
302
|
+
* on any map, `offscreen` or not. Change `viewport`/`<Source>`'s `data` the normal declarative
|
|
303
|
+
* way, then call `capturer.captureWhenSettled()`, which waits for the map to fully settle (see
|
|
304
|
+
* `onTilesLoaded`, reusing this same `tilesLoadedTimeout`/`tilesLoadedFadeMargin`) before reading
|
|
305
|
+
* the canvas. The result (a data URL) can be handed to any PDF/document library — this doesn't
|
|
306
|
+
* depend on or assume one. */
|
|
302
307
|
onCapturerReady?: (capturer: MapCapturer) => void;
|
|
308
|
+
/** Called if map initialization fails — e.g. `mapLib.supported()` reports the environment can't
|
|
309
|
+
* run Mapbox/MapLibre GL JS (any WebGL-less context, including Vitest/jsdom), or the underlying
|
|
310
|
+
* `new mapLib.Map(...)` constructor itself throws. Always logged via `console.error` in addition
|
|
311
|
+
* to this callback, so nothing is silently lost if it isn't provided — pass it to show fallback
|
|
312
|
+
* UI instead of (or alongside) the console log. */
|
|
313
|
+
onError?: (error: Error) => void;
|
|
303
314
|
/** Displays Map Tile Borders */
|
|
304
315
|
showTileBoundaries?: boolean;
|
|
305
316
|
/** Displays Wireframe if Terrain is visible */
|
|
@@ -349,7 +360,7 @@ type MapContextState = {
|
|
|
349
360
|
* light/dark judgment, just "something in the environment that could affect a resolved CSS
|
|
350
361
|
* value just changed." Layer reads this only to know *when* to re-probe a "bg-x dark:bg-y"
|
|
351
362
|
* color pair, never to decide which of the two applies (the browser's own cascade decides that,
|
|
352
|
-
* see resolveColor in
|
|
363
|
+
* see resolveColor in components/Layer/colors.ts) — so it stays correct even for a dark-mode strategy (e.g. a
|
|
353
364
|
* `data-theme` attribute) MapGL's own class-based heuristic wouldn't recognize as "dark" */
|
|
354
365
|
themeVersion: number;
|
|
355
366
|
};
|
|
@@ -375,26 +386,20 @@ declare const Source: Component<Props$a>;
|
|
|
375
386
|
|
|
376
387
|
type FlatLayerStyle = Record<string, any>;
|
|
377
388
|
type PulseConfig = {
|
|
378
|
-
/** The paint property to animate
|
|
379
|
-
* `*-color` property (e.g. `"icon-halo-color"`) to fade/shift a color
|
|
380
|
-
*
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
to
|
|
388
|
-
/** Full cycle length, in ms. Default `1500`. */
|
|
389
|
+
/** The paint property to animate — a number (e.g. `"circle-radius"`, `"icon-halo-width"`) or a
|
|
390
|
+
* `*-color` property (e.g. `"circle-color"`, `"icon-halo-color"`) to fade/shift a color. No
|
|
391
|
+
* default: which property makes sense depends entirely on the layer type, so this is required. */
|
|
392
|
+
property: string;
|
|
393
|
+
/** Value at the start of each ping — a number, or any CSS color string (hex, named, rgb/rgba, a
|
|
394
|
+
* Tailwind name, oklch(), ...) when animating a `*-color` property. */
|
|
395
|
+
from: number | string;
|
|
396
|
+
/** Value the ping ramps out to before holding and resetting. */
|
|
397
|
+
to: number | string;
|
|
398
|
+
/** Full cycle length, in ms: ramp-out, then hold at `to`, then reset. Default `1500`. */
|
|
389
399
|
duration?: number;
|
|
390
|
-
/**
|
|
391
|
-
*
|
|
392
|
-
|
|
393
|
-
* most common "pulsing dot" look.
|
|
394
|
-
* - `"in"`: the mirror of `"out"` — ramps from `to` down to `from`, holding at `from`.
|
|
395
|
-
* - `"in-out"`: smooth back-and-forth between `from` and `to`, forever (sine-eased) — e.g. a
|
|
396
|
-
* halo that grows and shrinks continuously, with no reset. */
|
|
397
|
-
waveform?: "in-out" | "out" | "in";
|
|
400
|
+
/** Fraction of `duration` spent held at `to` before the next reset (the remainder is the ramp).
|
|
401
|
+
* Default `0.25`, matching Tailwind's `animate-ping` timing. */
|
|
402
|
+
holdFraction?: number;
|
|
398
403
|
};
|
|
399
404
|
type Props$9 = {
|
|
400
405
|
id?: string;
|
|
@@ -420,15 +425,21 @@ type Props$9 = {
|
|
|
420
425
|
state: Record<string, any>;
|
|
421
426
|
};
|
|
422
427
|
/** An object that specifies the state of a feature in the layer. The object consists of an ID (either a number or a string) and an object containing the state. */
|
|
423
|
-
/**
|
|
424
|
-
*
|
|
425
|
-
*
|
|
426
|
-
*
|
|
427
|
-
*
|
|
428
|
-
*
|
|
429
|
-
*
|
|
430
|
-
*
|
|
431
|
-
|
|
428
|
+
/** A periodic "ping": each cycle resets to `from`, hands the ramp to `to` off to Mapbox's own
|
|
429
|
+
* paint-property transition, then holds at `to` until the next cycle — e.g. a growing/fading
|
|
430
|
+
* `circle-radius`/`circle-color` for a "pulsing dot" marker. Pass an array to drive several
|
|
431
|
+
* properties off one shared cycle (one `setInterval` per entry, all started together), e.g.
|
|
432
|
+
* `circle-radius` and `circle-color` together for a ring that grows *and* fades. Driven by real
|
|
433
|
+
* paint properties (not a swapped-out image), so it composes with any other paint value,
|
|
434
|
+
* including data-driven expressions on other properties of the same layer.
|
|
435
|
+
*
|
|
436
|
+
* Only touches the property twice per cycle (reset + ramp-start) — the ramp itself is animated
|
|
437
|
+
* by Mapbox, not a per-frame `setPaintProperty` loop — so between the ramp finishing and the
|
|
438
|
+
* next cycle's reset, the map genuinely goes idle instead of staying marked dirty forever. That
|
|
439
|
+
* matters beyond just performance: `@mapbox/mapbox-gl-draw`'s own mount logic and this
|
|
440
|
+
* library's `captureWhenSettled()`/`waitUntilSettled()` both depend on the map actually
|
|
441
|
+
* reaching `'idle'`/`loaded()` — a continuously-dirty map silently starves both. */
|
|
442
|
+
pulse?: PulseConfig | PulseConfig[];
|
|
432
443
|
children?: any;
|
|
433
444
|
} & layerEventTypes;
|
|
434
445
|
declare const Layer: Component<Props$9>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { b, a } from '../chunk/BTR7SKE6.js';
|
|
2
|
+
export { b as MapProvider, a as useMapContext } from '../chunk/BTR7SKE6.js';
|
|
3
|
+
import { template, isServer, use, insert, memo, createComponent, effect, setAttribute, className, classList, style } from 'solid-js/web';
|
|
4
|
+
import { createContext, createSignal, onMount, createEffect, on, onCleanup, useContext, createUniqueId, createMemo, splitProps, untrack } from 'solid-js';
|
|
5
|
+
|
|
6
|
+
var fe=["onMouseDown","onMouseUp","onMouseOver","onMouseOut","onMouseMove","onMouseEnter","onMouseLeave","onPreClick","onClick","onDblClick","onContextMenu","onTouchStart","onTouchEnd","onTouchCancel","onWheel","onResize","onRemove","onTouchMove","onMoveStart","onMove","onMoveEnd","onDragStart","onDrag","onDragEnd","onZoomStart","onZoom","onZoomEnd","onRotateStart","onRotate","onRotatEnd","onPitchStart","onPitch","onPitchEnd","onBoxZoomStart","onBoxZoomEnd","onBoxZoomCancel","onWebglContextLost","onWebglContextRestored","onLoad","onRender","onIdle","onError","onData","onStyleData","onSourceData","onDataLoading","onStyleDataLoading","onSourceDataLoading","onStyleImageMissing"],he=["onMouseDown","onMouseUp","onMouseOver","onMouseOut","onMouseMove","onMouseEnter","onMouseLeave","onClick","onDblClick","onContextMenu","onTouchStart","onTouchEnd","onTouchCancel"],ye=["onCreate","onDelete","onCombine","onUncombine","onUpdate","onSelectionchange","onModechange","onRender","onActionable"];var C="mapbox://styles/mapbox",A="https://raw.githubusercontent.com/",L="https://raw.githubusercontent.com/GIShub4/map-styles/main/",ee="https://assets.vector.hereapi.com/styles/",ve={mb:{standard:`${C}/standard`,light:`${C}/light-v11`,dark:`${C}/dark-v11`,street:`${C}/streets-v12`,outdoor:`${C}/outdoors-v12`,sat:`${C}/satellite-v9`,sat_street:`${C}/satellite-streets-v12`,nav_base:`${C}/navigation-guidance-day-v4`,nav_base_night:`${C}/navigation-guidance-night-v4`,nav:`${C}/navigation-day-v1`,nav_night:`${C}/navigation-night-v1`,basic:`${C}/cjf4m44iw0uza2spb3q0a7s41`,monochrome:`${C}/cjv6rzz4j3m4b1fqcchuxclhb`,leshine:`${C}/cjcunv5ae262f2sm9tfwg8i0w`,icecream:`${C}/cj7t3i5yj0unt2rmt3y4b5e32`,cali:`${C}/cjerxnqt3cgvp2rmyuxbeqme7`,northstar:`${C}/cj44mfrt20f082snokim4ungi`,mineral:`${C}/cjtep62gq54l21frr1whf27ak`,moonlight:`${C}/cj3kbeqzo00022smj7akz3o1e`,frank:`${C}-map-design/ckshxkppe0gge18nz20i0nrwq`,minimo:`${C}-map-design/cksjc2nsq1bg117pnekb655h1`,decimal:`${C}-map-design/ck4014y110wt61ctt07egsel6`,stand:`${C}-map-design/ckr0svm3922ki18qntevm857n`,blueprint:`${C}-map-design/cks97e1e37nsd17nzg7p0308g`,bubble:`${C}-map-design/cksysy2nl62zp17quosctdtcc`,pencil:`${C}-map-design/cks9iema71es417mlrft4go2k`,swiss_ski:`${A}mapbox/mapbox-gl-swiss-ski-style/master/cij1zoclj002y8rkkdjl69psd.json`,vintage:`${A}mapbox/mapbox-gl-vintage-style/master/cif5p01n202nisaktvljx9mv3.json`,whaam:`${A}mapbox/mapbox-gl-whaam-style/master/cii8323c8004w0nlvtss3dbm2.json`,neon:`${A}NatEvatt/awesome-mapbox-gl-styles/master/styles/Neon/style.json`,camoflauge:`${A}jingsam/mapbox-gl-styles/master/Camouflage.json`,emerald:`${A}jingsam/mapbox-gl-styles/master/Emerald.json`,runner:`${A}jingsam/mapbox-gl-styles/master/Runner.json`,x_ray:`${A}jingsam/mapbox-gl-styles/master/X-ray.json`},here:{base:`${ee}berlin/base/mapbox/tilezen?apikey={apikey}`,day:`${ee}berlin/day/mapbox/tilezen?apikey={apikey}`,night:`${ee}berlin/night/mapbox/tilezen?apikey={apikey}`},esri:{blueprint:`${L}esri:blueprint.json`,charted_territory:`${L}esri:charted-territory.json`,colored_pencil:`${L}esri:colored-pencil.json`,community:`${L}esri:community.json`,mid_century:`${L}esri:mid-century.json`,modern_antique:`${L}esri:modern-antique.json`,nat_geo:`${L}esri:national-geographic.json`,newspaper:`${L}esri:newspaper.json`,open_street_map:`${L}esri:open-street-map.json`,light_gray_canvas:`${L}esri:light-gray-canvas.json`,dark_gray_canvas:`${L}esri:dark-gray-canvas.json`,human_geo_light:`${L}esri:human-geography-light.json`,human_geo_dark:`${L}esri:human-geography-dark.json`,world_navigation:`${L}esri:world-navigation.json`,world_street:`${L}esri:world-street.json`,world_street_night:`${L}esri:world-street-night.json`,world_terrain:`${L}esri:world-terrain.json`,world_terrain_hybrid:`${L}esri:world-terrain-hybrid.json`,world_topographic:`${L}esri:world-topographic.json`,chromium:`${L}esri:chromium.json`,dreamcatcher:`${L}esri:dreamcatcher.json`,seahaven:`${L}esri:seahaven.json`,sangria:`${L}esri:sangria.json`,mercurial:`${L}esri:mercurial.json`,imagery:`${L}esri:imagery.json`,imagery_hybrid:`${L}esri:imagery-hybrid.json`,firefly:`${L}esri:firefly.json`,firefly_hybrid:`${L}esri:firefly-hybrid.json`,oceans:`${L}esri:oceans.json`}},te="https://{s}.basemaps.cartocdn.com/rastertiles/",N="https://stamen-tiles-{s}.a.ssl.fastly.net/",T="https://{s}.tile.thunderforest.com/",ne={osm:{org:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",human:"https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png",cycle:"https://{s}.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png",topo:"https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png",_copy:'<a href="https://www.openstreetmap.org/copyright" target="_blank">© OpenStreetMap</a>'},carto:{voyager:`${te}voyager_labels_under/{z}/{x}/{y}{r}.png`,positron:`${te}light_all/{z}/{x}/{y}{r}.png`,dark:`${te}dark_all/{z}/{x}/{y}{r}.png`,_copy:'<a href="https://carto.com/attribution" target="_blank">© Carto</a>'},stamen:{toner:`${N}toner/{z}/{x}/{y}{r}.png`,toner_lite:`${N}toner-lite/{z}/{x}/{y}{r}.png`,watercolor:`${N}watercolor/{z}/{x}/{y}.png`,terrain:`${N}terrain/{z}/{x}/{y}{r}.png`,_copy:'<a href="https://stamen.com/privacy-policy" target="_blank">© Stamen Design</a>'},tf:{cycle:`${T}cycle/{z}/{x}/{y}{r}.png?apikey={apikey}`,trans:`${T}transport/{z}/{x}/{y}{r}.png?apikey={apikey}`,trans_dark:`${T}transport-dark/{z}/{x}/{y}{r}.png?apikey={apikey}`,landscape:`${T}landscape/{z}/{x}/{y}{r}.png?apikey={apikey}`,outdoors:`${T}outdoors/{z}/{x}/{y}{r}.png?apikey={apikey}`,neighbourhood:`${T}neighbourhood/{z}/{x}/{y}{r}.png?apikey={apikey}`,spinal:`${T}spinal-map/{z}/{x}/{y}{r}.png?apikey={apikey}`,pioneer:`${T}pioneer/{z}/{x}/{y}{r}.png?apikey={apikey}`,atlas:`${T}atlas/{z}/{x}/{y}{r}.png?apikey={apikey}`,mobile:`${T}mobile-atlas/{z}/{x}/{y}{r}.png?apikey={apikey}`,_copy:'<a href="https://thunderforest.com/privacy" target="_blank">© Thunderforest</a>'}};var z=()=>new Promise(e=>requestAnimationFrame(()=>e())),He=e=>{try{return !!e.style?.hasTransitions?.()}catch{return false}};function Qe(e,t){return new Promise(n=>{let o=Date.now()+t,r=()=>{if(e.areTilesLoaded()){n(true);return}if(Date.now()>=o){n(false);return}setTimeout(r,100);};r();})}async function q(e,t={}){let{timeout:n=1e4,fadeMargin:o=400}=t;if(await Qe(e,n),e.triggerRepaint(),await z(),await z(),o>0){let r=Date.now()+Math.max(o,2e3);for(;He(e)&&Date.now()<r;)e.triggerRepaint(),await z();await new Promise(i=>setTimeout(i,o)),e.triggerRepaint(),await z(),await z();}}function G(e,t={}){return new Promise(n=>{e.once("idle",()=>{q(e,t).then(n);}),e.triggerRepaint();})}function oe(e){for(let t of e.getStyle()?.layers??[])try{e.setPaintProperty(t.id,"raster-fade-duration",0);}catch{}}function Me(e,t){return {map:e,waitUntilSettled:()=>G(e,t),capture:(n="image/jpeg",o=.92)=>e.getCanvas().toDataURL(n,o),captureWhenSettled:async(n="image/jpeg",o=.92)=>(await G(e,t),e.getCanvas().toDataURL(n,o))}}var it=template("<div>"),st=template("<style>.overlay{position:relative;width:100%;height:100%;pointer-events:none}:where(.overlay>*){pointer-events:auto}"),lt=template("<div class=overlay>"),mt=e=>{let t,n,o,r,i,a=false,l=0,[c,s]=createSignal(null),[g,m]=createSignal(0),[M,f]=createSignal(!isServer&&(window.matchMedia("(prefers-color-scheme: dark)").matches||document.body.classList.contains("dark"))),h=false,v=false,y=(d,p)=>(e.debug||e.debugEvents)&&console.debug("%c[MapGL]","color: #0ea5e9",d,p||""),b$1=(d,p)=>{let u=M()&&p?p:d;return (typeof u=="string"||u instanceof String)&&u?.split(":").reduce((x,P)=>x&&x[P],ve)?.replace("{apikey}",e.apikey||import.meta.env?.VITE_VECTOR_API_KEY)||u};onMount(async()=>{try{await S();}catch(d){console.error("[MapGL] Failed to initialize map:",d),e.onError?.(d);}});let S=async()=>{if(i=e.mapLib||await import('mapbox-gl'),i.Map||(i=window.maplibregl||window.mapboxgl),typeof i.supported=="function"&&!i.supported())throw new Error("Mapbox GL not supported");if(a=typeof i.Map?.prototype?.setConfigProperty!="function",y(`Map (v${i.version}) loading...`),t=new i.Map({accessToken:e.options?.accessToken||import.meta.env?.VITE_MAPBOX_ACCESS_TOKEN,interactive:e.options?.interactive||!!e.onViewportChange,...e.options,...e.viewport,projection:e.options?.projection,container:n,style:b$1(e.options?.style,e.darkStyle),fitBoundsOptions:{padding:e.viewport?.padding},...e.offscreen?{preserveDrawingBuffer:true}:{}}),t.debug=e.debug,t.debugEvents=e.debugEvents,t.sourceIdList=[],t.layerIdList=[],t.isMapLibre=a,fe.forEach(d=>{let p=e[d];if(p){let u=d.slice(2).toLowerCase();typeof p=="function"?t.on(u,x=>{setTimeout(()=>{u==="click"&&x.clickOnLayer||(p(x),e.debugEvents&&y(`Map '${u}' event:`,x));},0);}):Object.keys(p).forEach(x=>{t.on(u,x,P=>{setTimeout(()=>{u==="click"&&P.clickOnLayer||(p[x](P),e.debugEvents&&y(`Map '${u}' event on '${x}':`,P));},0);});});}}),e.onTilesLoaded){let d=e.tilesLoadedTimeout??1e4,p=e.tilesLoadedFadeMargin??400;t.on("idle",()=>{let u=++l;q(t,{timeout:d,fadeMargin:p}).then(()=>{u===l&&(y("Tiles settled"),e.onTilesLoaded());});});}t.once("load",()=>{s(t),y("Map loaded"),e.offscreen&&e.offscreen.disableRasterFade!==false&&oe(t),e.onCapturerReady&&e.onCapturerReady(Me(t,{timeout:e.tilesLoadedTimeout??1e4,fadeMargin:e.tilesLoadedFadeMargin??400})),["mousedown","touchstart","wheel"].forEach(p=>t.on(p,u=>!u.rotate&&e.onUserInteraction?.(true))),["moveend","mouseup","touchend"].forEach(p=>t.on(p,u=>!u.rotate&&e.onUserInteraction?.(false)));let d=!isServer&&window.matchMedia("(prefers-color-scheme: dark)");d?.addEventListener("change",()=>{f(d.matches),m(p=>p+1),y("Set dark theme to:",d.matches?.toString());}),r=new MutationObserver(()=>{let p=document.documentElement.classList.contains("dark")||document.body.classList.contains("dark");f(p),m(u=>u+1),y("Set theme to:",p);}),r.observe(document.documentElement,{attributes:true}),r.observe(document.body,{attributes:true}),e.disableResize||(o=new ResizeObserver(()=>{setTimeout(()=>{t?.resize();},0),y("Map resized");}),o.observe(n)),t.on("move",p=>{let u={...e.viewport,id:e.id,point:{x:p.originalEvent?.x,y:p.originalEvent?.y},center:e.viewport?.center?.lat?t.getCenter():[t.getCenter().lng,t.getCenter().lat],zoom:t.getZoom(),pitch:t.getPitch(),bearing:t.getBearing(),inTransit:true,bounds:null};!p.viewport&&e.onViewportChange&&(v=true,e.onViewportChange(u));}),t.on("moveend",p=>{if(h||p.rotate||!e.onViewportChange)return;let u={...e.viewport,inTransit:false};v=true,e.onViewportChange(u);});});};createEffect(on(()=>e.viewport,d=>{if(!t||e.id!==d?.id)return;if(v){v=false;return}let p={...d,...d.bounds?t.cameraForBounds(d.bounds,{bearing:d?.bearing,pitch:d?.pitch,padding:d?.padding}):null};h=true,t.stop(),h=false,t[e.transitionType||"flyTo"](p),y(`Update Viewport (${e.transitionType||"flyTo"}):`,p);},{defer:true})),createEffect(()=>{let d=c();if(typeof d?.setConfigProperty!="function"){d&&e.config&&Object.keys(e.config).length&&y("Config prop is set but this map library has no setConfigProperty (Mapbox Standard Style only) \u2014 skipping");return}for(let p in e.config){if(!p||p==="id")continue;let u=e.config?.id||"basemap",x=e.config[p];d.setConfigProperty(u,p,x),y(`Set Config (${u}:${p}) to:`,x);}}),createEffect(()=>{let d=e.options?.projection;!t||!d||(t.setProjection(d),y("Set Projection to:",d));}),createEffect(()=>{let d=e.cursorStyle;!t||!d||(t.getCanvas().style.cursor=d,y("Set Cursor to:",d));});let k=(d,p)=>(p.forEach(u=>{let x=d.findIndex(P=>u.metadata.smg.beforeType?P.type===u.metadata.smg.beforeType:P.id===u.metadata.smg.beforeId);d=x===-1?[...d,u]:[...d.slice(0,x),u,...d.slice(x)];}),d);return createEffect(d=>{let p=b$1(e.options?.style,e.darkStyle);if(t?.isStyleLoaded()&&d!==p){let u=t.getStyle(),x=u.layers.filter(_=>t.layerIdList.includes(_.id)),P=Object.keys(u.sources).filter(_=>t.sourceIdList.includes(_)).reduce((_,ge)=>({..._,[ge]:u.sources[ge]}),{}),K=e.shouldDiffStyle?e.shouldDiffStyle(d,p):true;t.setStyle(p,K?void 0:{diff:false}),t.once("styledata",()=>{if(!x)return;let _=t.getStyle();t.setStyle({..._,sources:{..._.sources,...P},layers:k(_.layers,x),fog:u.fog,terrain:u.terrain,light:u.light}),y("Set Mapstyle to:",p);});}return p},e.options?.style),["showTileBoundaries","showTerrainWireframe","showCollisionBoxes","showPadding","showOverdrawInspector"].forEach(d=>{createEffect(()=>{let p=e[d];!t||!p||(t[d]=p,y(`Set ${d} to:`,p));});}),onCleanup(()=>{o?.disconnect(),r?.disconnect(),l++,t?.remove(),y("Map removed");}),(()=>{var d=it(),p=n;return typeof p=="function"?use(p,d):n=d,insert(d,(()=>{var u=memo(()=>!!c());return ()=>u()&&createComponent(b,{get map(){return c()},mapLib:i,isMapLibre:a,get constants(){return e.constants},get themeVersion(){return g()},get children(){return [st(),(()=>{var x=lt();return insert(x,()=>e.children),x})()]}})})()),effect(u=>{var x=e.id,P=e?.class,K=e?.classList,_=e.offscreen?{position:"fixed",left:"-99999px",top:"-99999px",width:`${e.offscreen.width}px`,height:`${e.offscreen.height}px`,...e.style}:{width:"100%",height:"100%",...e.style};return x!==u.e&&setAttribute(d,"id",u.e=x),P!==u.t&&className(d,u.t=P),u.a=classList(d,K,u.a),u.o=style(d,_,u.o),u},{e:void 0,t:void 0,a:void 0,o:void 0}),d})()};var we=createContext(),V=()=>useContext(we),vt=e=>{let[t]=a();e.id??=createUniqueId();let n=(i,a)=>{t.map.debug&&console.debug("%c[MapGL]","color: #ec4899",i,a||"");},o=()=>e.source,r=i=>{let a=i?.split(":").reduce((c,s)=>c&&c[s],ne),l=a?{...o(),url:"",tiles:[a.replace("{apikey}",o().apikey||import.meta.env?.VITE_RASTER_API_KEY).replace("{r}",window.devicePixelRatio>1?"@2x":"")],attribution:ne[i.split(":")[0]]._copy}:o();return l.tiles&&(l.tiles=["a","b","c"].map(c=>l.tiles[0].replace("{s}",c))),l};switch(t.map.addSource(e.id,r(o().url)),t.map.sourceIdList.push(e.id),n("Add Source:",e.id),o().type){case "geojson":createEffect(()=>{let i=o().data;t.map.getSource(e.id).setData(i||{}),n("Update GeoJSON Data:",e.id);});break;case "image":createEffect(()=>{let i=o().url,a=o().coordinates;t.map.getSource(e.id).updateImage(i,a),n("Update Image Data:",e.id);});break;case "vector":createEffect(()=>{let i=o().url,a=o().tiles,l=t.map.getSource(e.id);i?l.setUrl(i):l.setTiles(a),n("Update Vector Data:",e.id);});break;case "raster":createEffect(()=>{let i=r(o().url),a=t.map.getSource(e.id);i.url?a.setUrl(i.url):a.setTiles(i.tiles),n("Update Raster Data:",e.id);});break}return onCleanup(()=>{t.map?.getStyle().layers.forEach(i=>i.source===e.id&&t.map.removeLayer(i.id)),t.map?.getSource(e.id)&&t.map?.removeSource(e.id),n("Remove Source:",e.id);}),createComponent(we.Provider,{get value(){return e.id},get children(){return e.children}})};var Le=["id","type","filter","source","source-layer","minzoom","metadata","maxzoom","paint","layout"],Ce=["visibility","line-join","line-cap","line-miter-limit","line-round-limit","line-sort-key","circle-sort-key","symbol-avoid-edges","symbol-placement","symbol-sort-key","symbol-spacing","symbol-z-order","icon-allow-overlap","icon-anchor","icon-ignore-placement","icon-image","icon-keep-upright","icon-offset","icon-optional","icon-padding","icon-pitch-alignment","icon-rotate","icon-rotation-alignment","icon-size","icon-text-fit","icon-text-fit-padding","text-allow-overlap","text-anchor","text-field","text-font","text-ignore-placement","text-justify","text-keep-upright","text-letter-spacing","text-line-height","text-max-angle","text-max-width","text-offset","text-optional","text-padding","text-pitch-alignment","text-radial-offset","text-rotate","text-rotation-alignment","text-size","text-transform","text-variable-anchor","text-writing-mode"];var O,Se=e=>(O??=document.body.appendChild(document.createElement("div")),O.style.cssText="position:absolute;visibility:hidden;pointer-events:none",O.style.color="",O.style.color=e,O.style.color?getComputedStyle(O).color:void 0),Mt=/^[a-z]+-\d{2,3}$/,bt=/^(rgb|rgba|hsl|hsla)\(/i,xt=/^[a-z-]+\(/i,U,wt=/^bg-[a-z]+-\d{2,3}(?:\s+dark:bg-[a-z]+-\d{2,3})?$/,Lt=e=>{U??=document.body.appendChild(document.createElement("div")),U.style.cssText="position:absolute;visibility:hidden;pointer-events:none",U.className=e;let t=getComputedStyle(U).backgroundColor;return U.className="",t&&t!=="rgba(0, 0, 0, 0)"?t:e},Pe=e=>{if(wt.test(e))return Lt(e);if(Mt.test(e)){let t=getComputedStyle(document.documentElement).getPropertyValue(`--color-${e}`).trim();return t&&Se(t)||e}return xt.test(e)&&!bt.test(e)&&Se(e)||e};var ke=(e={},t={})=>[...new Set([...Object.keys(e),...Object.keys(t)])].reduce((o,r)=>{let i=e[r];return i!==t[r]&&o.push([r,i]),o},[]),ie=(e,t)=>(e.startsWith(t)||e.startsWith("icon")||e.startsWith("text")?"":t+"-")+e.replace(/[A-Z]/g,n=>"-"+n.toLowerCase()),Pt=["slot","filter","visible","beforeId","beforeType"],X=(e,t)=>e.endsWith("color")?Array.isArray(t)?t.map(n=>X(e,n)):typeof t=="string"?Pe(t):t:t,Et=/^@(.+)$/,Y=(e,t,n,o)=>{if(Array.isArray(t))return t.map(a=>Y(e,a,n,o));if(typeof t!="string")return t;let r=t.match(Et);if(!r)return t;let i=n[r[1]];return i===void 0?(o(`Unknown constant "@${r[1]}" referenced by "${e}" \u2014 leaving unresolved`),t):i},se=(e,t={},n=()=>{})=>{if(!e)return;let o={},r={},i={},a=(l,c)=>X(l,Y(l,c,t,n));return Object.entries(e).forEach(([l,c])=>{if(Le.includes(l))i[l]=c;else {Pt.includes(l)&&n(`"${l}" is a <Layer> prop, not a style property \u2014 belongs outside "style", not inside it. Treating it as a paint/layout property instead.`);let s=ie(l,e.type);Ce.includes(s)?o[s]=Y(s,c,t,n):r[s]=a(s,c);}}),e.paint&&Object.entries(e.paint).forEach(([l,c])=>{let s=ie(l,e.type);r[s]=a(s,c);}),e.layout&&Object.entries(e.layout).forEach(([l,c])=>{let s=ie(l,e.type);o[s]=Y(s,c,t,n);}),{...i,paint:r,layout:o}},kt=e=>{let[t]=a(),n=e.sourceId||e.style?.source||V(),o=e.id||e.customLayer?.id||createUniqueId(),r=(a,l)=>{(t.map.debug||t.map.debugEvents)&&console.debug("%c[MapGL]","color: #10b981",a,l||"");},i=createMemo(()=>e.beforeType?t.map.getStyle().layers.find(a=>a.type===e.beforeType)?.id:e.beforeId);return t.map.addLayer(e.customLayer||{...se(e.style,t.constants,r),id:o,source:n,...t.isMapLibre?{}:{slot:e.slot||""},metadata:{smg:{beforeType:e.beforeType,beforeId:e.beforeId}}},i()),t.map.layerIdList.push(o),e.customLayer&&t.map.fire("load"),r("Add Layer:",o),he.forEach(a=>{if(e[a]){let l=a.slice(2).toLowerCase();t.map.on(l,o,c=>{l==="click"&&(c.clickOnLayer=true),e[a](c),t.map.debugEvents&&r(`Layer '${l}' event on '${o}':`,c);});}}),createEffect(a=>{t.themeVersion;let l=se(e.style,t.constants,r);if(l!==a)return l.layout!==a?.layout&&ke(l.layout,a?.layout).forEach(([c,s])=>t.map.setLayoutProperty(o,c,s,{validate:false})),l.paint!==a?.paint&&ke(l.paint,a?.paint).forEach(([c,s])=>t.map.setPaintProperty(o,c,s,{validate:false})),(l.minzoom!==a?.minzoom||l.maxzoom!==a?.maxzoom)&&t.map.setLayerZoomRange(o,l.minzoom,l.maxzoom),l.filter!==a?.filter&&t.map.setFilter(o,l.filter,{validate:false}),r("Update Layer Style:",o),l},se(e.style,t.constants,r)),createEffect(a=>{if(e.visible!==a)return t.map.setLayoutProperty(o,"visibility",e.visible?"visible":"none",{validate:false}),r(`Update Visibility (${o}):`,e.visible.toString()),e.visible},e.visible),createEffect(a=>i()===a?a:(t.map.moveLayer(o,i()),r(`Update Layer Z-Index (${o}):`,i()),i()),i()),createEffect(a=>e.filter===a||a===void 0&&!e.filter?a:(t.map.setFilter(o,e.filter??null),r(`Update Filter (${o}):`,e.filter),e.filter),void 0),createEffect(async()=>{!e.featureState||e.featureState.id===null||(!t.map.isStyleLoaded()&&await t.map.once("styledata"),t.map.removeFeatureState({source:n,sourceLayer:e.style["source-layer"]}),t.map.setFeatureState({source:n,sourceLayer:e.style["source-layer"],id:e.featureState.id},e.featureState.state));}),createEffect(()=>{if(!e.pulse)return;let l=(Array.isArray(e.pulse)?e.pulse:[e.pulse]).map(c=>{let{property:s,duration:g=1500,holdFraction:m=.25}=c,M=X(s,c.from),f=X(s,c.to),h=g*(1-m),v=()=>{t.map.setPaintProperty(o,`${s}-transition`,{duration:0,delay:0},{validate:false}),t.map.setPaintProperty(o,s,M,{validate:false}),requestAnimationFrame(()=>{t.map.setPaintProperty(o,`${s}-transition`,{duration:h,delay:0},{validate:false}),t.map.setPaintProperty(o,s,f,{validate:false});});};return v(),window.setInterval(v,g)});r(`Start Pulse (${o}):`,e.pulse),onCleanup(()=>l.forEach(c=>window.clearInterval(c)));}),onCleanup(()=>t.map?.getLayer(o)&&t.map?.removeLayer(o)),e.children};var _e=createContext(),Rt=()=>useContext(_e),zt=e=>{let[t]=a(),[n,o]=createSignal(null);return onMount(async()=>{e.id=e.id||createUniqueId();let r=t.mapLib.MercatorCoordinate.fromLngLat([e.origin[0]||0,e.origin[1]||0],e.origin[2]||0),i=r.meterInMercatorCoordinateUnits(),{x:a,y:l,z:c}=r,s=null,g=null,m=null;e.babylon?(g=await import('@babylonjs/core'),s=g.Matrix.Compose(new g.Vector3(i,i,i),g.Quaternion.FromEulerAngles(Math.PI/2,0,0),new g.Vector3(a,l,c))):(m=await import('three'),s={translateX:a,translateY:l,translateZ:c,rotateX:Math.PI/2,rotateY:0,rotateZ:0,scale:i}),t.map.addLayer({id:e.id,type:"custom",renderingMode:"3d",onAdd(M,f){if(e.babylon){let h=new g.Engine(f,true,{useHighPrecisionMatrix:true},true);this.scene=new g.Scene(h),this.scene.autoClear=false,this.scene.preventDefaultOnPointerDown=false,this.scene.preventDefaultOnPointerUp=false;let v=new g.UniversalCamera("Camera",g.Vector3.Zero());v.mode=g.Camera.ORTHOGRAPHIC_CAMERA,v.inertia=0,this.scene.ambientColor=new g.Color3(1,1,1),e.defaultLight&&new g.HemisphericLight("Light",new g.Vector3(100,10,0),this.scene);}else this.camera=new m.Camera,this.scene=new m.Scene,e.defaultLight&&(this.light=new m.DirectionalLight(16777215),this.light.position.set(100,0,0).normalize(),this.scene.add(this.light)),this.renderer=new m.WebGLRenderer({canvas:M.getCanvas(),context:f,antialias:true}),this.renderer.autoClear=false;this.map=M,e.onAdd&&e.onAdd(this.scene,this.map,f),o(this.scene);},render(M,f){if(e.babylon){this.scene.activeCamera.freezeProjectionMatrix(s.multiply(g.Matrix.FromArray(f)));this.map.getPitch()*(Math.PI/180);this.map.getBearing()*(Math.PI/180);this.scene.render(false);}else {let h=new m.Matrix4().makeRotationAxis(new m.Vector3(1,0,0),s.rotateX),v=new m.Matrix4().makeRotationAxis(new m.Vector3(0,1,0),s.rotateY),y=new m.Matrix4().makeRotationAxis(new m.Vector3(0,0,1),s.rotateZ),b=new m.Matrix4().fromArray(f),S=new m.Matrix4().makeTranslation(s.translateX,s.translateY,s.translateZ).scale(new m.Vector3(s.scale,-s.scale,s.scale)).multiply(h).multiply(v).multiply(y);this.camera.projectionMatrix=b.multiply(S),this.renderer.resetState(),this.renderer.render(this.scene,this.camera);}e.onRender&&e.onRender(M,f),t.map.triggerRepaint();}},e.beforeId);}),onCleanup(()=>{t.map.getLayer(e.id)&&t.map.removeLayer(e.id);}),createComponent(_e.Provider,{value:n,get children(){return memo(()=>!!n())()&&e.children}})};var jt=e=>{let[t]=a();return createEffect(()=>{t.isMapLibre?t.map.setSky?.(e.style||{}):t.map.setFog(e.style||{});}),onCleanup(()=>{t.isMapLibre?t.map.getSky?.()&&t.map.setSky(null):t.map.getFog()&&t.map.setFog(null);}),null};var Gt=e=>{let[t]=a(),n=V();return !n&&!e?.source&&(n=createUniqueId(),t.map.addSource(n,{type:"raster-dem",url:t.isMapLibre?"https://demotiles.maplibre.org/terrain-tiles/tiles.json":"mapbox://mapbox.terrain-rgb",tileSize:t.isMapLibre?256:512,maxzoom:t.isMapLibre?void 0:14}),t.map.sourceIdList.push(n)),createEffect(()=>{t.map.setTerrain({exaggeration:e.exaggeration||1,source:e?.source||n});}),onCleanup(()=>t.map?.setTerrain(null)),null};var W=(e,t)=>{let[n]=a();createEffect(()=>{let o=e(),r=t?.();o&&(n.map.hasControl(o)&&n.map.removeControl(o),n.map.addControl(o,r));}),onCleanup(()=>{let o=e();o&&n.map.hasControl(o)&&n.map.removeControl(o);});};var Kt=e=>{let[t]=a(),[n,o]=splitProps(e,["position"]),[r,i]=createSignal(null),a$1=new Map([["navigation",t.mapLib.NavigationControl],["scale",t.mapLib.ScaleControl],["attribution",t.mapLib.AttributionControl],["geolocate",t.mapLib.GeolocateControl],["fullscreen",t.mapLib.FullscreenControl],["logo",t.mapLib.LogoControl],["terrain",t.mapLib.TerrainControl]]);return createEffect(()=>{untrack(()=>r()&&t.map.hasControl(r())&&t.map.removeControl(r())),i(o.custom||new(a$1.get(o.type||"navigation"))(o.options));}),W(r,()=>n.position),null};var tn=e=>{if(!e.lngLat)throw new Error("Marker - lngLat is required");let[t,n,o]=splitProps(e,["lngLat","children","showPopup","draggable"],["popup","onOpen","onClose"]),[r]=a(),i=null,a$1=null,l=t.lngLat;return createEffect(()=>{r.map&&(a$1?.remove(),a$1=new r.mapLib.Popup({closeOnClick:false,focusAfterOpen:false,...n.popup}).on("open",()=>n.onOpen?.()).on("close",()=>n.onClose?.()),createEffect(()=>{t.children!==void 0&&(typeof t.children=="string"?a$1?.setHTML(t.children):a$1?.setDOMContent(t.children),i?.setPopup(a$1));}),createEffect(()=>t.showPopup!==a$1?.isOpen()&&i?.togglePopup()));}),createEffect(()=>{r.map&&(i?.remove(),i=new r.mapLib.Marker(o.options).on("dragstart",()=>o.onDragStart?.()).on("dragend",()=>o.onDragEnd?.()).on("drag",()=>o.onDrag?.(i?.getLngLat().toArray())).setPopup(a$1).setLngLat(l).addTo(r.map),createEffect(()=>t.showPopup!==a$1?.isOpen()&&i?.togglePopup()));}),createEffect(()=>i?.setLngLat(t.lngLat)),createEffect(()=>i?.setDraggable(t.draggable)),onCleanup(()=>i?.remove()),null};var rn=e=>{if(!e.trackPointer&&!e.lngLat)throw new Error("Popup - lngLat or trackPointer is required");let[t,n]=splitProps(e,["lngLat","children","trackPointer"]),[o]=a(),r;return createEffect(()=>{o.map&&(r?.remove(),r=new o.mapLib.Popup({closeOnClick:false,focusAfterOpen:false,...n.options}).on("open",()=>n.onOpen?.()).on("close",()=>n.onClose?.()).addTo(o.map),createEffect(()=>t.trackPointer?r.trackPointer():r.setLngLat(t.lngLat)),createEffect(()=>typeof t.children=="string"?r.setHTML(t.children):r.setDOMContent(t.children)));}),onCleanup(()=>r?.remove()),null};var ce=new Float64Array(256);for(let e=0;e<256;e++){let t=.5-Math.pow(e/255,.45454545454545453);ce[e]=t*Math.abs(t);}ce[255]=-1e20;function Ie(e,t,n,o,r,i,a){i[0]=0,a[0]=-1e20,a[1]=1e20,r[0]=e[t];for(let l=1,c=0,s=0;l<o;l++){r[l]=e[t+l*n];let g=l*l;do{let m=i[c];s=(r[l]-r[m]+g-m*m)/(l-m)/2;}while(s<=a[c]&&--c>-1);c++,i[c]=l,a[c]=s,a[c+1]=1e20;}for(let l=0,c=0;l<o;l++){for(;a[c+1]<l;)c++;let s=i[c],g=l-s;e[t+l*n]=r[s]+g*g;}}function Te(e,t,n,o,r,i){for(let a=0;a<t;a++)Ie(e,a,t,n,o,r,i);for(let a=0;a<n;a++)Ie(e,a*t,1,t,o,r,i);}var de=({radius:e=8}={})=>Math.ceil(e);function H(e,{radius:t=8,cutoff:n=.25}={}){let{width:o,height:r}=e,i=o*r,a=new Float64Array(i).fill(1e20),l=new Float64Array(i),c=Math.max(o,r),s=new Float64Array(c),g=new Uint16Array(c),m=new Float64Array(c+1),M=e.data;for(let y=0,b=3;y<i;y++,b+=4){let S=M[b];if(S===0)continue;let k=ce[S];a[y]=Math.max(0,k),l[y]=Math.max(0,-k);}Te(a,o,r,s,g,m),Te(l,o,r,s,g,m);let f=255/t,h=255*(1-n),v=new Uint8ClampedArray(i*4);for(let y=0,b=0;y<i;y++,b+=4){let S=Math.sqrt(a[y])-Math.sqrt(l[y]),k=Math.max(0,Math.min(255,Math.round(h-f*S)));v[b]=v[b+1]=v[b+2]=255,v[b+3]=k;}return {width:o,height:r,data:v}}var ue={diagonal_l:{size:20,path:"M20 0 0 20M-10 10 10-10M10 30 30 10"},diagonal_r:{size:20,path:"M0 0 20 20M30 10 10-10M10 30-10 10"},horizontal:{size:14,path:"M7 0V20"},vertical:{size:14,path:"M0 7H20"},cross:{size:18,path:"M9 0V18M0 9H18"},hash:{size:30,path:"M15 0 30 15 15 30 0 15Z"},chevron_h:{size:20,path:"M-5 5 0 10 10 0 20 10 25 5M0 30 10 20 20 30"},chevron_v:{size:20,path:"M5-5 10 0 0 10 10 20 5 25M25 15 20 10 25 5"},square:{size:20,path:"M8 8H12V12H8Z",fill:true},hex:{size:50,path:"M0 0V50L50 25ZM50 0V50L0 25ZM25 0V50"},circle:{size:25,path:"M8 10A2.5 2.5 0 118.01 10M18 15A2.5 2.5 0 1018.01 15",fill:true},grid:{size:20,path:"M10 0V20M0 10H20"},brick:{size:40,path:"M0 0H40M0 20H40M0 40H40M0 0V20M20 0V20M40 0V20M10 20V40M30 20V40"},wave:{size:20,path:"M0 5Q5 0 10 5T20 5M0 15Q5 10 10 15T20 15"}},$e=Object.keys(ue),E=e=>`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" stroke-linecap="round" stroke-linejoin="round">
|
|
7
|
+
<path d="${e}" fill="#000" stroke="#000" stroke-width="3"/>
|
|
8
|
+
</svg>`,me={square:E("M3,3 L21,3 L21,21 L3,21 Z"),circle:E("M 12 4 A 1 1 0 0 0 12 20 A 1 1 0 0 0 12 4 Z"),triangle:E("M 12 2 L 22 19 H 2 Z"),diamond:E("M 12 1 L 19 12 L 12 23 L 5 12 Z"),pentagon:E("M12,3 L21,9 L17,19 L7,19 L3,9 Z"),hexagon:E("M12,3 L20,7.5 L20,16.5 L12,21 L4,16.5 L4,7.5 Z"),octagon:E("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"),cross:E("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"),x:E("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"),star:E("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"),heart:E("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"),pin:E("M 12 21 L 7 11 A 6 6 0 0 1 12 2 A 6 6 0 0 1 17 11 Z"),drop:E("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"),chevron:E("M 8 4 L 14 12 L 8 20 H 5 L 11 12 L 5 4 Z")},Ae=Object.keys(me),De=e=>E(e);var dn=e=>{let[t]=a(),[n,o]=createSignal({width:0,height:0}),r=null,i=(s,g)=>{t.map.debug&&console.debug("%c[MapGL]","color: #10b981",s,g||"");},a$1=()=>{!r||!t.map||t.map.hasImage(e.id)||(t.map.addImage(e.id,r.data,r.ops),i("Re-Add Image:",e.id));};t.map.on("style.load",a$1),onCleanup(()=>{t.map?.off("style.load",a$1),t.map?.hasImage(e.id)&&t.map?.removeImage(e.id),i("Remove Image:",e.id);}),createEffect(()=>{if(!e.id)throw new Error("Image - ID is required");if(!e.source&&!e.pattern&&!e.symbol)throw new Error("Image - Image, Pattern or Symbol is required");let s=Math.max(1,Math.round(window.devicePixelRatio||2)),g=e.pattern?{pixelRatio:s,...e.options}:e.sdf?{...e.options,sdf:true}:e.options,m=e.symbol&&(me[e.symbol]||(e.symbol.trimStart().startsWith("<svg")?e.symbol:De(e.symbol)));l(e.source||m||c(e.pattern,s),(M,f)=>{let h=f?{...g,pixelRatio:f}:g,{width:v,height:y}=M;t.map&&!t.map.hasImage(e.id)&&t.map.addImage(e.id,M,h),!e.pattern&&untrack(()=>v===n().width&&y===n().height)?(t.map.updateImage(e.id,M),t.map.triggerRepaint()):(t.map.removeImage(e.id),t.map.addImage(e.id,M,h)),o({width:v,height:y}),r={data:M,ops:h},i("Add Image:",e.id);});});let l=(s,g)=>{let m=e.sdf?typeof e.sdf=="object"?e.sdf:{}:null;if(typeof s=="string"&&s?.trimStart().startsWith("<svg")&&(s=new DOMParser().parseFromString(s,"image/svg+xml").childNodes[0]),s instanceof SVGElement&&(e.options?.fill&&s.setAttribute("fill",e.options.fill),e.options?.stroke&&s.setAttribute("stroke",e.options.stroke),s=new XMLSerializer().serializeToString(s)),typeof s!="string")return g(s);t.map.loadImage(s,async(M,f)=>{if(M){typeof s=="string"&&s?.trimEnd().endsWith(".svg")&&(s=await(await fetch(s)).text(),s=new DOMParser().parseFromString(s,"image/svg+xml").childNodes[0],s.setAttribute("fill",e.options.fill),s.setAttribute("stroke",e.options.stroke),s.setAttribute("transform",e.options.transform),s=new XMLSerializer().serializeToString(s));let h=new Image;h.crossOrigin="Anonymous",h.onload=()=>{let v=Math.min(h.width,h.height),y=v>0?Math.max(1,50/v):1,b=e.options?.pixelRatio??Math.max(1,Math.round(window.devicePixelRatio||1)),S=y*b,k=m?de(m)*S:0,d=Math.round(h.width*S),p=Math.round(h.height*S),u=document.createElement("canvas");u.width=d+k*2,u.height=p+k*2;let x=u.getContext("2d");x.imageSmoothingEnabled=true,x.drawImage(h,k,k,d,p);let P=x.getImageData(0,0,u.width,u.height);return g(m?H(P,m):P,S)},h.onerror=v=>console.error(`[MapGL] Image "${e.id}" failed to load:`,v),h.src=s.trimStart().startsWith("<svg")?"data:image/svg+xml;charset=utf-8,"+encodeURIComponent(s):s;}else {if(!m)return g(f);let{width:h,height:v}=f,y=de(m),b=document.createElement("canvas");b.width=h+y*2,b.height=v+y*2;let S=b.getContext("2d");S.imageSmoothingEnabled=true,"data"in f?S.putImageData(f,y,y):S.drawImage(f,y,y,h,v);let k=S.getImageData(0,0,b.width,b.height);return g(H(k,m))}});},c=(s,g=2)=>{let m=ue[s.type],M=m.size*g;return {width:M,height:M,data:new Uint8Array(M*M*4),onAdd:function(){let f=document.createElement("canvas");f.width=f.height=M,this.ctx=f.getContext("2d",{willReadFrequently:true}),this.ctx.scale(g,g);},render:function(){return this.ctx.fillStyle=s.background||"transparent",this.ctx.fillRect(0,0,m.size,m.size),this.ctx.strokeStyle=this.ctx.fillStyle=s.color||"black",this.ctx.lineWidth=s.lineWidth||1,this.ctx.stroke(new Path2D(m.path)),m.fill&&this.ctx.fill(new Path2D(m.path)),this.data=this.ctx.getImageData(0,0,this.width,this.height).data,true}}};return null};var pn=(e,t,n)=>e.map((o,r)=>(1-n)*e[r]+n*t[r]),gn=(e,t,n)=>{let o=e.map((i,a)=>e[a]*t[a]).reduce((i,a)=>i+a),r=Math.acos(o);return e.map((i,a)=>Math.sin((1-n)*r)/Math.sin(r)*e[a]+Math.sin(n*r)/Math.sin(r)*t[a])},fn={in:e=>e*e,out:e=>1-(1-e)*(1-e),inOut:e=>e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2},hn=e=>{let[t]=a(),n=.1,o=false,[r,i]=createSignal(false);["mousedown","touchstart","wheel"].forEach(f=>t.map.on(f,h=>!h.rotate&&i(true))),["moveend","mouseup","touchend"].forEach(f=>t.map.on(f,h=>!h.rotate&&i(false)));let a$1=async([f,h,v],y)=>{let b=t.map.getFreeCameraOptions();b.position=t.mapLib.MercatorCoordinate.fromLngLat([f,h],v),b.lookAtPoint(y),t.map.setFreeCameraOptions(b);},l=()=>{e.translate&&window.requestAnimationFrame(l);let f=[e.translate.start,e.translate.end,e.translate.easing?fn[e.translate.easing](n):n],h=e.translate.type==="line"?pn(...f):gn(...f);a$1(h,e.translate.target),!e.translate.loop&&(n>1||n<0)&&(o=!o),n=o?n-.001:n+.001;};createEffect(()=>{e.translate&&window.requestAnimationFrame(l);});let c={duration:1e3,easing:f=>f},s=()=>{if(r())return;let{secPerRev:f=120,maxSpinZoom:h=5,slowSpinZoom:v=3}=e.rotateGlobe,y=t.map.getZoom();if(y>h)return;let b=360/f;y>v&&(b*=(h-y)/(h-v));let S=t.map.getCenter();S.lng=e.reverse?S.lng+b:S.lng-b,t.map.easeTo({center:S,...c},{rotate:true});},g=()=>{if(!e.rotateViewport||r()){t.map.stop();return}let f=e.rotateViewport,h=f?.secPerRev||60,v=e.reverse?t.map.getBearing()+360/h:t.map.getBearing()-360/h,y=f?.pitch||60,b=f?.around;t.map.easeTo({bearing:v,pitch:y,around:b,...c},{rotate:true});},m=()=>e.rotateGlobe?s():g();t.map.on("moveend",m).on("dragend",m);let M;return createEffect(()=>{e.rotateGlobe!=null&&(e.rotateGlobe?(M=t.map.getCenter(),s()):e.resetWhenStopped?t.map.stop().easeTo({center:M}):t.map.stop());}),createEffect(()=>{e.rotateViewport!=null&&(e.rotateViewport?g():e.resetWhenStopped?t.map.stop().resetNorthPitch():t.map.stop());}),onCleanup(()=>t.map.off("moveend",m).off("dragend",m)),e.children};var Mn=e=>{let[t]=a();return createEffect(()=>t.map.setLight(e.style||{})),onCleanup(()=>t.map?.setLight(null)),null};var j={};j.onSetup=function(e){var t={};return t.count=e.count||0,t};j.onClick=function(e,t){var n=this.newFeature({type:"Feature",properties:{count:e.count},geometry:{type:"Point",coordinates:[t.lngLat.lng,t.lngLat.lat]}});this.addFeature(n);};j.onKeyUp=function(e,t){if(t.keyCode===27)return this.changeMode("simple_select")};j.toDisplayFeatures=function(e,t,n){n(t);};var Fe=j;var bn=6371.0088,xn=1.609344,Oe=6378137;function I(e){return e*Math.PI/180}function Re(e){return e*180/Math.PI}function wn(e,t){let n=I(t[1]-e[1]),o=I(t[0]-e[0]),r=I(e[1]),i=I(t[1]),a=Math.sin(n/2)**2+Math.cos(r)*Math.cos(i)*Math.sin(o/2)**2;return bn*2*Math.asin(Math.sqrt(a))}function Z(e,t="kilometers"){let n=0;for(let o=1;o<e.length;o++)n+=wn(e[o-1],e[o]);return t==="miles"?n/xn:n}function ze(e,t){let n=I(e[1]),o=I(e[0]),r=I(t[1]),i=I(t[0]-e[0]),a=Math.cos(r)*Math.cos(i),l=Math.cos(r)*Math.sin(i),c=Math.atan2(Math.sin(n)+Math.sin(r),Math.sqrt((Math.cos(n)+a)**2+l**2)),s=o+Math.atan2(l,Math.cos(n)+a);return [Re(s),Re(c)]}function Ln(e){let t=e.length;if(t<=2)return 0;let n=0;for(let o=0;o<t;o++){let r,i,a;o===t-2?(r=t-2,i=t-1,a=0):o===t-1?(r=t-1,i=0,a=1):(r=o,i=o+1,a=o+2),n+=(I(e[a][0])-I(e[r][0]))*Math.sin(I(e[i][1]));}return n*Oe*Oe/2}function Ve(e){return e.reduce((t,n,o)=>{let r=Math.abs(Ln(n));return o===0?t+r:t-r},0)}function Ue(e){let t=e[0],n=0,o=0;for(let[c,s]of t)n+=c,o+=s;n/=t.length,o/=t.length;let r=0,i=0,a=0;for(let c=0;c<t.length-1;c++){let s=t[c][0]-n,g=t[c][1]-o,m=t[c+1][0]-n,M=t[c+1][1]-o,f=s*M-m*g;r+=(s+m)*f,i+=(g+M)*f,a+=f;}if(a===0)return [n,o];let l=1/(3*a);return [n+r*l,o+i*l]}var je=e=>new Intl.NumberFormat(void 0,{maximumFractionDigits:5}).format(e[0])+"\xB0 "+new Intl.NumberFormat(void 0,{maximumFractionDigits:5}).format(e[1])+"\xB0",$=(e,t)=>{let n=Z(e,window.navigator.language==="en-US"?"miles":"kilometers");return {type:"Feature",properties:{type:"measure",value:window.navigator.language==="en-US"?new Intl.NumberFormat(void 0,{style:"unit",maximumFractionDigits:2,unit:n<=1?"foot":"mile"}).format(n<=1?n*5280:n):new Intl.NumberFormat(void 0,{style:"unit",maximumFractionDigits:2,unit:n<=1?"meter":"kilometer"}).format(n<=1?n*1e3:n),...t},geometry:{type:"Point",coordinates:ze(e[0],e[1])}}},Q=(e,t)=>{let n=Ve(e);return {type:"Feature",properties:{type:"measure",value:window.navigator.language==="en-US"?new Intl.NumberFormat(void 0,{style:"unit",maximumFractionDigits:2,unit:n<=10.764?"foot":"mile"}).format(n<=10.764?n*10.764:n*1.0000003861)+"\xB2":new Intl.NumberFormat(void 0,{style:"unit",maximumFractionDigits:2,unit:n<=1e6?"meter":"kilometer"}).format(n<=1e6?n:n/1e6)+"\xB2",...t},geometry:{type:"Point",coordinates:Ue(e)}}};var Ze=e=>{let t=e.modes.draw_line_string;return {...t,onSetup:function(){let n=t.onSetup.call(this),o=this.newFeature({type:"Feature",properties:{type:"measure",value:"TTT"},geometry:{type:"Point",coordinates:[]}});return {...n,measure:o}},onMouseMove:function(n,o){if(t.onMouseMove.call(this,n,o),n.line.coordinates.length>=2){let r=$(n.line.coordinates);n.measure.properties.value=r.properties.value,n.measure.updateCoordinate("",r.geometry.coordinates[0],r.geometry.coordinates[1]);}},toDisplayFeatures:function(n,o,r){t.toDisplayFeatures.call(this,n,o,r),this.drawConfig.userProperties.showLength&&r(n.measure.toGeoJSON());}}};var Ne=e=>{let t=e.modes.draw_point;return {...t,onSetup:function(){let n=t.onSetup.call(this);return n.point.properties={...n.point.properties,type:"measure",anchor:"bottom"},n},onMouseMove:function(n,{lngLat:o}){n.point.properties.value=je([o.lng,o.lat]),n.point.updateCoordinate("",o.lng,o.lat);},toDisplayFeatures:function(n,o,r){let i=o.properties.id===n.point.id;return o.properties.active=i?"":"false",r(o)}}};var qe=e=>{let t=e.modes.draw_polygon;return {...t,toDisplayFeatures:function(n,o,r){let i=a=>{if(r(a),this.drawConfig.userProperties.showLength){let l=Array.isArray(a.geometry.coordinates[0][0])?a.geometry.coordinates[0]:a.geometry.coordinates;l.forEach((c,s)=>{!Array.isArray(c)||s==0||r($([l[s-1],c]));});}this.drawConfig.userProperties.showArea&&a.geometry.coordinates[0].length>=3&&r(Q([a.geometry.coordinates[0]]));};t.toDisplayFeatures.call(this,n,o,i);}}};function Cn(e,t,n,o){return {type:"Feature",properties:{meta:"vertex",parent:e,coord_path:n,active:o?"true":"false"},geometry:{type:"Point",coordinates:t}}}function Sn(e,t,n,o=64){let r=[],i=t/(111.32*Math.cos(e[1]*Math.PI/180)),a=t/110.574;for(let l=0;l<o;l+=1){let c=l/o*(2*Math.PI),s=i*Math.cos(c),g=a*Math.sin(c);r.push([e[0]+s,e[1]+g]);}return r.push(r[0]),{type:"Feature",geometry:{type:"Polygon",coordinates:[r]},properties:{parent:n,active:"true"}}}var Pn={enable:e=>{setTimeout(()=>{!e.map||!e.map.doubleClickZoom||!e._ctx||!e._ctx.store||!e._ctx.store.getInitialConfigValue||e._ctx.store.getInitialConfigValue("doubleClickZoom")&&e.map.doubleClickZoom.enable();},0);}},En=e=>({...e.modes.draw_line_string,clickAnywhere:function(t,n){return t.currentVertexPosition===1?(t.line.addCoordinate(0,n.lngLat.lng,n.lngLat.lat),this.changeMode("simple_select",{featureIds:[t.line.id]})):(this.updateUIClasses({mouse:"add"}),t.line.updateCoordinate(t.currentVertexPosition,n.lngLat.lng,n.lngLat.lat),t.direction==="forward"?(t.currentVertexPosition+=1,t.line.updateCoordinate(t.currentVertexPosition,n.lngLat.lng,n.lngLat.lat)):t.line.addCoordinate(0,n.lngLat.lng,n.lngLat.lat),null)},onStop:function(t){if(Pn.enable(this),this.activateUIButton(),this.getFeature(t.line.id)!==void 0)if(t.line.removeCoordinate("0"),t.line.isValid()){let n=t.line.toGeoJSON(),o=(Z(n.geometry.coordinates)*1e3).toFixed(1),r=n.geometry.coordinates[0];this.deleteFeature([t.line.id],{silent:true});let i=this.newFeature({type:"Feature",properties:{radius:o},geometry:{type:"Point",coordinates:r}});this.addFeature(i),this.map.fire("draw.create",{features:[i.toGeoJSON()]}),this.changeMode("simple_select",{featureIds:[i.id]});}else this.deleteFeature([t.line.id],{silent:true}),this.changeMode("simple_select",{},{silent:true});},toDisplayFeatures:function(t,n,o){let r=n.properties.id===t.line.id;return n.properties.active=r?"true":"false",r?(n.geometry.coordinates.length<2||(n.properties.meta="feature",o(Cn(t.line.id,n.geometry.coordinates[t.direction==="forward"?n.geometry.coordinates.length-2:1],`${t.direction==="forward"?n.geometry.coordinates.length-2:1}`,false)),o(n),o($(n.geometry.coordinates,{parent:t.line.id})),o(Sn(n.geometry.coordinates[0],Z(n.geometry.coordinates),t.line.id))),null):o(n)}}),Ge=En;var kn=e=>({...e.modes.draw_line_string,onSetup:function(t){let n=e.modes.draw_line_string.onSetup.call(this,t),o=this.newFeature({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[]]}});return this.addFeature(o),{...n,...t,rectangle:o}},onTap:function(t,n){t.startPoint&&this.onMouseMove(t,n),this.onClick(t,n);},onClick:function(t,n){t.startPoint&&t.startPoint[0]!==n.lngLat.lng&&t.startPoint[1]!==n.lngLat.lat?(this.updateUIClasses({mouse:"pointer"}),t.endPoint=[n.lngLat.lng,n.lngLat.lat],this.changeMode("simple_select",{featuresId:t.rectangle.id})):t.startPoint=[n.lngLat.lng,n.lngLat.lat];},onMouseMove:function(t,n){t.startPoint&&(t.rectangle.updateCoordinate("0.0",t.startPoint[0],t.startPoint[1]),t.rectangle.updateCoordinate("0.1",n.lngLat.lng,t.startPoint[1]),t.rectangle.updateCoordinate("0.2",n.lngLat.lng,n.lngLat.lat),t.rectangle.updateCoordinate("0.3",t.startPoint[0],n.lngLat.lat),t.rectangle.updateCoordinate("0.4",t.startPoint[0],t.startPoint[1]));},onKeyUp:function(t,n){if(n.keyCode===27)return this.changeMode("simple_select")},onStop:function(t){e.modes.draw_line_string.onStop.call(this,t),this.getFeature(t.rectangle.id)!==void 0&&(t.rectangle.removeCoordinate("0.4"),t.rectangle.isValid()?this.map.fire("draw.create",{features:[t.rectangle.toGeoJSON()]}):(this.deleteFeature([t.rectangle.id],{silent:true}),this.changeMode("simple_select",{},{silent:true})));},toDisplayFeatures:function(t,n,o){let r=n.properties.id===t.rectangle.id;if(n.properties.active=r?"true":"false",!r)return o(n);if(t.startPoint)return o(n),this.drawConfig.userProperties.showLength&&(o($([n.geometry.coordinates[0][0],n.geometry.coordinates[0][1]],{parent:t.rectangle.id,anchor:"bottom"})),o($([n.geometry.coordinates[0][1],n.geometry.coordinates[0][2]],{parent:t.rectangle.id,anchor:"left"}))),this.drawConfig.userProperties.showArea&&o(Q(n.geometry.coordinates,{parent:t.rectangle.id})),null},onTrash:function(t){this.deleteFeature([t.rectangle.id],{silent:true}),this.changeMode("simple_select");}}),Be=kn;var Ye={enable:e=>{setTimeout(()=>{!e.map||!e.map.doubleClickZoom||!e._ctx||!e._ctx.store||!e._ctx.store.getInitialConfigValue||e._ctx.store.getInitialConfigValue("doubleClickZoom")&&e.map.doubleClickZoom.enable();},0);},disable(e){setTimeout(()=>{!e.map||!e.map.doubleClickZoom||e.map.doubleClickZoom.disable();},0);}},_n={onSetup:function(e){let t=this.newFeature({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[]]}});return this.addFeature(t),this.clearSelectedFeatures(),Ye.disable(this),this.updateUIClasses({mouse:"add"}),this.setActionableState({trash:true}),{rectangle:t,currentVertexPosition:0}},onTap:function(e,t){this.onClick(e,t);},onClick:function(e,t){if(e.currentVertexPosition===2){let n=this.calculatepXY3(e,t,false);return n&&e.rectangle.updateCoordinate(`0.${e.currentVertexPosition+1}`,n[0],n[1]),this.updateUIClasses({mouse:"pointer"}),this.changeMode("simple_select",{featuresId:e.rectangle.id})}else e.rectangle.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),e.currentVertexPosition++,e.rectangle.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat);},onMouseMove:function(e,t){if(e.rectangle.updateCoordinate("0."+e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),e.currentVertexPosition&&e.currentVertexPosition>0&&this.calculateOrientedAnglePolygon(e),e.currentVertexPosition===2){let n=this.calculatepXY3(e,t,true);n&&e.rectangle.updateCoordinate("0."+(e.currentVertexPosition+1),n[0],n[1]);}},deegrees2meters(e){let t=e[0]*2003750834e-2/180,n=Math.log(Math.tan((90+e[1])*Math.PI/360))/(Math.PI/180);return n=n*2003750834e-2/180,[t,n]},meters2degress(e){let t=e[0]*180/2003750834e-2,n=Math.atan(Math.exp(e[1]*Math.PI/2003750834e-2))*360/Math.PI-90;return [t,n]},calculateOrientedAnglePolygon:function(e){let t=e.rectangle.getCoordinate("0.0"),n=this.deegrees2meters(t),o=e.rectangle.getCoordinate("0.1"),r=this.deegrees2meters(o),a=-1*(Math.atan2(r[1]-n[1],r[0]-n[0])*180/Math.PI+90),l=a<0?a+360:a;e.angle=parseFloat(l.toFixed(2));},calculatepXY3:function(e,t,n){let o=e.rectangle.getCoordinate("0.0"),r=this.deegrees2meters(o),i=e.rectangle.getCoordinate("0.1"),a=this.deegrees2meters(i),l=this.deegrees2meters([t.lngLat.lng,t.lngLat.lat]),c=this.deegrees2meters([t.lngLat.lng,t.lngLat.lat]);if(r[0]===a[0])l=[c[0],a[1]];else if(r[1]===a[1])l=[a[0],c[1]];else {let h=-1/((a[1]-r[1])/(a[0]-r[0]));Math.abs(h)<1?l[1]=h*(c[0]-a[0])+a[1]:l[0]=a[0]+(l[1]-a[1])/h;}let s=[a[0]-r[0],a[1]-r[1]],g=[l[0]-s[0],l[1]-s[1]],m=this.meters2degress(l),M=this.meters2degress(g);return e.rectangle.updateCoordinate("0.2",m[0],m[1]),e.rectangle.updateCoordinate("0.3",M[0],M[1]),M},onKeyUp:function(e,t){if(t.keyCode===27)return this.changeMode("simple_select")},onStop:function(e){Ye.enable(this),this.updateUIClasses({mouse:"none"}),this.activateUIButton(),this.getFeature(e.rectangle.id)!==void 0&&(e.rectangle.removeCoordinate("0.4"),e.rectangle.isValid()?this.map.fire("draw.create",{features:[e.rectangle.toGeoJSON()]}):(this.deleteFeature([e.rectangle.id],{silent:true}),this.changeMode("simple_select",{},{silent:true})));},toDisplayFeatures:function(e,t,n){let o=t.properties.id===e.rectangle.id;if(t.properties.active=o?"true":"false",t.properties.angle=e.angle,t.angle=e.angle,!o)return n(t);let r=t.geometry.coordinates[0].length;if(r<3){let i=t.geometry.coordinates[0][0],a={type:"Feature",properties:t.properties,angle:e.angle,geometry:{coordinates:t.geometry.coordinates[0][0],type:"Point"}};i&&n(a);return}if(r>=3&&r<=4){let i=[[t.geometry.coordinates[0][0][0],t.geometry.coordinates[0][0][1]],[t.geometry.coordinates[0][1][0],t.geometry.coordinates[0][1][1]]];if(n({type:"Feature",properties:t.properties,angle:e.angle,geometry:{coordinates:i,type:"LineString"}}),r===3)return}return n(t)},onTrash:function(e){this.deleteFeature([e.rectangle.id],{silent:true}),this.changeMode("simple_select");}},Xe=_n;var We=[{id:"measure-label",type:"symbol",filter:["all",["==","$type","Point"],["==","user_type","measure"]],layout:{"text-field":["get","user_value"],"text-anchor":["get","user_anchor"],"text-offset":["match",["get","user_anchor"],"bottom",[0,-0.5],[0,0]],"text-size":12,"text-allow-overlap":true,"text-ignore-placement":true},paint:{"text-halo-color":"rgba(255,255,255,0.75)","text-halo-width":2,"text-halo-blur":1,"text-color":"#000"}}];var Tn=e=>{let[t]=a();t.isMapLibre&&e.lib.constants?.classes&&Object.assign(e.lib.constants.classes,{CANVAS:"maplibregl-canvas",CONTROL_BASE:"maplibregl-ctrl",CONTROL_PREFIX:"maplibregl-ctrl-",CONTROL_GROUP:"maplibregl-ctrl-group",ATTRIBUTION:"maplibregl-ctrl-attrib"});let n=new e.lib({styles:[...e.lib.lib.theme,...We],modes:{...e.lib.modes,draw_point:Ne(e.lib),draw_line_string:Ze(e.lib),draw_polygon:qe(e.lib),multi_point:Fe,radius:Ge(e.lib),rectangle:Be(e.lib),rectangle_assisted:Xe},userProperties:{showLength:e.showLength||false,showArea:e.showArea||false},...e.options});t.map.addControl(n,e.position||"top-right"),e.getInstance&&e.getInstance(n);let o={};return ye.forEach(r=>{if(e[r]){let i=`draw.${r.slice(2).toLowerCase()}`,a=l=>e[r](l);o[i]=a,t.map.on(i,a);}}),onCleanup(()=>{Object.keys(o).forEach(r=>t.map.off(r,o[r])),t.map?.removeControl(n);}),null};var An=e=>{let[t]=a(),n;return W(()=>(n||(n=new e.overlay(e.props||{})),n)),createEffect(()=>n?.setProps(e.props||{})),null};
|
|
9
|
+
|
|
10
|
+
export { jt as Atmosphere, hn as Camera, Kt as Control, An as DeckOverlay, Tn as Draw, dn as Image, kt as Layer, zt as Layer3D, Mn as Light, tn as Marker, rn as Popup, vt as Source, Gt as Terrain, mt as default, oe as disableRasterFade, $e as patternList, q as settleAfterIdle, Ae as symbolList, H as toSDF, Rt as useScene, V as useSourceId, G as waitForIdleAndSettle };
|