isard 1.1.0 → 1.2.0
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/CHANGELOG.md +33 -0
- package/dist/basemap/basemaps.d.ts +1 -1
- package/dist/basemap/basemaps.js +2 -2
- package/dist/basemap/basemaps.js.map +1 -1
- package/dist/basemap/grid.d.ts +5 -5
- package/dist/basemap/grid.js +59 -65
- package/dist/basemap/grid.js.map +1 -1
- package/dist/basemap/mvt.d.ts +1 -1
- package/dist/basemap/mvt.js +6 -6
- package/dist/basemap/mvt.js.map +1 -1
- package/dist/basemap/pmtiles.d.ts +10 -10
- package/dist/basemap/pmtiles.js +39 -31
- package/dist/basemap/pmtiles.js.map +1 -1
- package/dist/basemap/resample.d.ts +2 -2
- package/dist/basemap/resample.js +16 -14
- package/dist/basemap/resample.js.map +1 -1
- package/dist/basemap/terrain.d.ts +3 -3
- package/dist/basemap/terrain.js +6 -6
- package/dist/basemap/terrain.js.map +1 -1
- package/dist/basemap/vectorstyle.d.ts +12 -10
- package/dist/basemap/vectorstyle.js +128 -110
- package/dist/basemap/vectorstyle.js.map +1 -1
- package/dist/basemap/vectortiles.d.ts +11 -11
- package/dist/basemap/vectortiles.js +141 -103
- package/dist/basemap/vectortiles.js.map +1 -1
- package/dist/basemap/wmts.d.ts +3 -3
- package/dist/basemap/wmts.js +16 -11
- package/dist/basemap/wmts.js.map +1 -1
- package/dist/basemap.worker.js +2 -2
- package/dist/basemap.worker.js.map +14 -13
- package/dist/bind/layers.d.ts +13 -4
- package/dist/bind/layers.js +64 -40
- package/dist/bind/layers.js.map +1 -1
- package/dist/data/crs.d.ts +10 -10
- package/dist/data/crs.js +38 -34
- package/dist/data/crs.js.map +1 -1
- package/dist/data/gpx.d.ts +1 -1
- package/dist/data/gpx.js +20 -20
- package/dist/data/gpx.js.map +1 -1
- package/dist/data/kml.d.ts +1 -1
- package/dist/data/kml.js +42 -39
- package/dist/data/kml.js.map +1 -1
- package/dist/data/topojson.d.ts +1 -1
- package/dist/data/topojson.js +15 -10
- package/dist/data/topojson.js.map +1 -1
- package/dist/data/xml.d.ts +5 -5
- package/dist/data/xml.js +19 -18
- package/dist/data/xml.js.map +1 -1
- package/dist/decoder.worker.js +4 -4
- package/dist/decoder.worker.js.map +6 -6
- package/dist/engine/decoders.d.ts +2 -2
- package/dist/engine/decoders.js +28 -25
- package/dist/engine/decoders.js.map +1 -1
- package/dist/engine/loader.js +13 -14
- package/dist/engine/loader.js.map +1 -1
- package/dist/engine/requests.d.ts +1 -1
- package/dist/engine/requests.js +19 -16
- package/dist/engine/requests.js.map +1 -1
- package/dist/engine-loader.d.ts +8 -8
- package/dist/engine-loader.js +27 -27
- package/dist/engine-loader.js.map +1 -1
- package/dist/geoplateforme.d.ts +10 -10
- package/dist/geoplateforme.js +22 -20
- package/dist/geoplateforme.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js.map +1 -1
- package/dist/isard_bg.wasm +0 -0
- package/dist/isard_core_bg.wasm +0 -0
- package/dist/isard_points_bg.wasm +0 -0
- package/dist/layers/extrusions.d.ts +1 -1
- package/dist/layers/extrusions.js +10 -5
- package/dist/layers/extrusions.js.map +1 -1
- package/dist/layers/features.d.ts +10 -10
- package/dist/layers/features.js +41 -42
- package/dist/layers/features.js.map +1 -1
- package/dist/layers/glyphs.d.ts +3 -3
- package/dist/layers/glyphs.js +34 -40
- package/dist/layers/glyphs.js.map +1 -1
- package/dist/layers/icons.d.ts +8 -8
- package/dist/layers/icons.js +76 -68
- package/dist/layers/icons.js.map +1 -1
- package/dist/layers/layers.d.ts +1 -1
- package/dist/layers/layers.js +33 -29
- package/dist/layers/layers.js.map +1 -1
- package/dist/layers/panoramas.d.ts +2 -2
- package/dist/layers/panoramas.js +52 -41
- package/dist/layers/panoramas.js.map +1 -1
- package/dist/layers/pointclouds.d.ts +3 -3
- package/dist/layers/pointclouds.js +25 -33
- package/dist/layers/pointclouds.js.map +1 -1
- package/dist/layers/symbols.d.ts +1 -1
- package/dist/layers/symbols.js +68 -71
- package/dist/layers/symbols.js.map +1 -1
- package/dist/map/basemap-layers.d.ts +26 -0
- package/dist/map/basemap-layers.js +61 -0
- package/dist/map/basemap-layers.js.map +1 -0
- package/dist/map/canvas.d.ts +17 -0
- package/dist/map/canvas.js +56 -0
- package/dist/map/canvas.js.map +1 -0
- package/dist/map/checks.d.ts +11 -0
- package/dist/map/checks.js +39 -0
- package/dist/map/checks.js.map +1 -0
- package/dist/map/credits.d.ts +17 -0
- package/dist/map/credits.js +34 -0
- package/dist/map/credits.js.map +1 -0
- package/dist/map/engine-settings.d.ts +15 -0
- package/dist/map/engine-settings.js +45 -0
- package/dist/map/engine-settings.js.map +1 -0
- package/dist/map/engines.d.ts +41 -0
- package/dist/map/engines.js +77 -0
- package/dist/map/engines.js.map +1 -0
- package/dist/map/events.d.ts +14 -0
- package/dist/map/events.js +46 -0
- package/dist/map/events.js.map +1 -0
- package/dist/map/frame-loop.d.ts +61 -0
- package/dist/map/frame-loop.js +139 -0
- package/dist/map/frame-loop.js.map +1 -0
- package/dist/map/hover-pick.d.ts +30 -0
- package/dist/map/hover-pick.js +56 -0
- package/dist/map/hover-pick.js.map +1 -0
- package/dist/map/layer-spec.d.ts +42 -0
- package/dist/map/layer-spec.js +34 -0
- package/dist/map/layer-spec.js.map +1 -0
- package/dist/map/layer-stack.d.ts +36 -0
- package/dist/map/layer-stack.js +101 -0
- package/dist/map/layer-stack.js.map +1 -0
- package/dist/map/overlay-host.d.ts +36 -0
- package/dist/map/overlay-host.js +101 -0
- package/dist/map/overlay-host.js.map +1 -0
- package/dist/map/panorama-host.d.ts +5 -0
- package/dist/map/panorama-host.js +32 -0
- package/dist/map/panorama-host.js.map +1 -0
- package/dist/map/raster-source.d.ts +11 -0
- package/dist/map/raster-source.js +26 -0
- package/dist/map/raster-source.js.map +1 -0
- package/dist/map/symbol-atlases.d.ts +26 -0
- package/dist/map/symbol-atlases.js +59 -0
- package/dist/map/symbol-atlases.js.map +1 -0
- package/dist/map/viewshed.d.ts +5 -0
- package/dist/map/viewshed.js +28 -0
- package/dist/map/viewshed.js.map +1 -0
- package/dist/map/workers.d.ts +46 -0
- package/dist/map/workers.js +73 -0
- package/dist/map/workers.js.map +1 -0
- package/dist/map.d.ts +33 -120
- package/dist/map.js +164 -689
- package/dist/map.js.map +1 -1
- package/dist/react/Control.d.ts +11 -0
- package/dist/react/Control.js +18 -0
- package/dist/react/Control.js.map +1 -0
- package/dist/react/CustomLayer.d.ts +11 -0
- package/dist/react/CustomLayer.js +30 -0
- package/dist/react/CustomLayer.js.map +1 -0
- package/dist/react/IsardMap.d.ts +43 -0
- package/dist/react/IsardMap.js +146 -0
- package/dist/react/IsardMap.js.map +1 -0
- package/dist/react/Layer.d.ts +42 -0
- package/dist/react/Layer.js +74 -0
- package/dist/react/Layer.js.map +1 -0
- package/dist/react/Marker.d.ts +24 -0
- package/dist/react/Marker.js +53 -0
- package/dist/react/Marker.js.map +1 -0
- package/dist/react/Panel.d.ts +11 -0
- package/dist/react/Panel.js +37 -0
- package/dist/react/Panel.js.map +1 -0
- package/dist/react/Popup.d.ts +18 -0
- package/dist/react/Popup.js +60 -0
- package/dist/react/Popup.js.map +1 -0
- package/dist/react/Swipe.d.ts +9 -0
- package/dist/react/Swipe.js +41 -0
- package/dist/react/Swipe.js.map +1 -0
- package/dist/react/Viewshed.d.ts +5 -0
- package/dist/react/Viewshed.js +28 -0
- package/dist/react/Viewshed.js.map +1 -0
- package/dist/react/context.d.ts +32 -0
- package/dist/react/context.js +20 -0
- package/dist/react/context.js.map +1 -0
- package/dist/react/index.d.ts +15 -108
- package/dist/react/index.js +10 -397
- package/dist/react/index.js.map +1 -1
- package/dist/settings.d.ts +5 -9
- package/dist/settings.js +17 -15
- package/dist/settings.js.map +1 -1
- package/dist/types.d.ts +3 -3
- package/dist/types.js.map +1 -1
- package/dist/ui/controls.js +6 -4
- package/dist/ui/controls.js.map +1 -1
- package/dist/ui/interaction.d.ts +2 -2
- package/dist/ui/interaction.js +8 -7
- package/dist/ui/interaction.js.map +1 -1
- package/dist/ui/overlay.js +18 -20
- package/dist/ui/overlay.js.map +1 -1
- package/dist/ui/style.d.ts +1 -1
- package/dist/ui/style.js +2 -2
- package/dist/ui/style.js.map +1 -1
- package/dist/util/animation.d.ts +3 -3
- package/dist/util/animation.js +6 -6
- package/dist/util/animation.js.map +1 -1
- package/dist/util/color.d.ts +1 -1
- package/dist/util/color.js +14 -16
- package/dist/util/color.js.map +1 -1
- package/dist/util/geo.d.ts +6 -6
- package/dist/util/geo.js +12 -12
- package/dist/util/geo.js.map +1 -1
- package/dist/util/guards.d.ts +7 -0
- package/dist/util/guards.js +8 -0
- package/dist/util/guards.js.map +1 -0
- package/dist/util/lru.js.map +1 -1
- package/dist/wasm/isard.d.ts +168 -0
- package/dist/wasm/isard.js +146 -0
- package/dist/wasm/isard_core.d.ts +144 -0
- package/dist/wasm/isard_core.js +122 -0
- package/dist/workers/basemap.worker.d.ts +3 -3
- package/dist/workers/basemap.worker.js +94 -83
- package/dist/workers/basemap.worker.js.map +1 -1
- package/package.json +1 -1
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAEL,aAAa,EACb,aAAa,EACb,UAAU,EAEV,UAAU,EACV,SAAS,EACT,mBAAmB,EACnB,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE9E,OAAO,EAAE,MAAM,EAAkB,MAAM,WAAW,CAAC;AAEnD,OAAO,EAEL,MAAM,IAAI,YAAY,EACtB,KAAK,IAAI,WAAW,EAEpB,KAAK,IAAI,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,aAAa,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;AAChF,CAAC","sourcesContent":["/**\n * Isard in React: the map, its layers, markers, popups, panels and effects as components, created when they mount,\n * updated by the least their props need and removed when they unmount.\n *\n * ```tsx\n * <IsardMap preset=\"ign-3d\" center={[2.35, 48.85]} zoom={15} style={{ height: 400 }}>\n * <Layer type=\"lines\" data={routes} color=\"#0057b8\" width={3} />\n * <Marker lonLat={[2.35, 48.85]}><Popup>Here</Popup></Marker>\n * </IsardMap>\n * ```\n */\n\nimport {\n type CSSProperties,\n createContext,\n createElement,\n forwardRef,\n type ReactNode,\n useContext,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { applyLayerChange, LayerOrder, layerChange } from '../bind/layers.ts';\nimport type { Layer as LayerHandle } from '../layers/layers.ts';\nimport { GeoMap, type LayerSpec } from '../map.ts';\nimport type { GeoMapOptions, LonLat, MapEvents, Point, SwipeOptions, ViewshedOptions } from '../types.ts';\nimport {\n type Anchor,\n Marker as MarkerHandle,\n Panel as PanelHandle,\n type PanelOptions,\n Popup as PopupHandle,\n type PopupOptions,\n} from '../ui/overlay.ts';\nimport type { Camera } from '../wasm/isard.js';\n\n// ── The map ──\n\ninterface Binding {\n map: GeoMap;\n order: LayerOrder;\n /** The observers of the `<Viewshed>` components, set on the map together */\n viewsheds: Map<object, ViewshedOptions>;\n applyViewsheds(): void;\n}\n\nconst MapContext = createContext<Binding | undefined>(undefined);\n\n/** The map of the `<IsardMap>` around, once created (undefined before) */\nexport function useMap(): GeoMap | undefined {\n return useContext(MapContext)?.map;\n}\n\n/** Listens to an event of the map around while the component is mounted; the listener may change at each render */\nexport function useMapEvent<K extends keyof MapEvents>(type: K, listener: (event: MapEvents[K]) => void): void {\n const map = useMap();\n const latest = useRef(listener);\n latest.current = listener;\n useEffect(() => map?.on(type, (event) => latest.current(event)), [map, type]);\n}\n\n/** The props of the map's events: `onClick` for 'click', `onMoveEnd` for 'moveend'… */\nexport interface MapEventProps {\n onMoveStart?: (camera: Camera) => void;\n onMove?: (camera: Camera) => void;\n onMoveEnd?: (camera: Camera) => void;\n onResize?: (event: MapEvents['resize']) => void;\n onHover?: (event: MapEvents['hover']) => void;\n onHoverFeature?: (event: MapEvents['hoverfeature']) => void;\n onClick?: (event: MapEvents['click']) => void;\n onRender?: (event: MapEvents['render']) => void;\n onIdle?: () => void;\n onLeave?: () => void;\n}\n\nconst EVENT_PROPS = {\n onMoveStart: 'movestart',\n onMove: 'move',\n onMoveEnd: 'moveend',\n onResize: 'resize',\n onHover: 'hover',\n onHoverFeature: 'hoverfeature',\n onClick: 'click',\n onRender: 'render',\n onIdle: 'idle',\n onLeave: 'leave',\n} as const satisfies Record<keyof MapEventProps, keyof MapEvents>;\n\nexport interface IsardMapProps extends Omit<GeoMapOptions, keyof Camera>, MapEventProps {\n /** The camera at creation, then left to the user's gestures */\n center?: LonLat;\n zoom?: number;\n pitch?: number;\n bearing?: number;\n /** A camera the map follows: set again whenever it changes (with `onMove` to keep it in a state) */\n camera?: Partial<Camera>;\n /** The map, once created */\n onLoad?: (map: GeoMap) => void;\n /** The map's creation failed (no WebGL2, the engine not found) */\n onError?: (error: unknown) => void;\n id?: string;\n className?: string;\n style?: CSSProperties;\n /** Layers, markers, popups, panels, effects; drawn once the map is created */\n children?: ReactNode;\n}\n\n/** Options the map takes again after its creation, and how */\nconst LIVE_OPTIONS: { [K in keyof GeoMapOptions]?: (map: GeoMap, props: IsardMapProps) => void } = {\n basemap: (map, p) => {\n if (p.basemap) map.setBasemap(p.basemap, p.hillshade);\n },\n hillshade: (map, p) => {\n if (p.basemap) map.setBasemap(p.basemap, p.hillshade);\n },\n terrain: (map, p) => map.setTerrain(p.terrain ?? false),\n minZoom: (map, p) => map.setMinZoom(p.minZoom ?? 0),\n maxZoom: (map, p) => map.setMaxZoom(p.maxZoom ?? 22),\n maxPitch: (map, p) => map.setMaxPitch(p.maxPitch ?? 70),\n atmosphere: (map, p) => map.setAtmosphere(p.atmosphere),\n projection: (map, p) => map.setProjection(p.projection ?? 'globe'),\n loading: (map, p) => map.setLoading(p.loading ?? 'immediate'),\n sky: (map, p) => map.setSky(p.sky ?? true),\n background: (map, p) => {\n if (p.background) map.setBackground(p.background);\n },\n};\n\nfunction sameCamera(a: Camera, b: Partial<Camera>): boolean {\n return (\n (b.center === undefined || (a.center[0] === b.center[0] && a.center[1] === b.center[1])) &&\n (b.zoom === undefined || a.zoom === b.zoom) &&\n (b.pitch === undefined || a.pitch === b.pitch) &&\n (b.bearing === undefined || a.bearing === b.bearing)\n );\n}\n\n/**\n * A map filling its element (give it a height). Created once mounted, destroyed when unmounted; the options read at\n * creation only (`body`, `preset`, `interactive`, the URLs) need a new `key` to take another value\n */\nexport const IsardMap = forwardRef<GeoMap | undefined, IsardMapProps>(function IsardMap(props, ref) {\n const element = useRef<HTMLDivElement>(null);\n const [binding, setBinding] = useState<Binding>();\n const latest = useRef(props);\n latest.current = props;\n useImperativeHandle(ref, () => binding?.map, [binding]);\n\n useEffect(() => {\n const container = element.current;\n if (!container) return;\n let cancelled = false;\n let created: GeoMap | undefined;\n const { camera, center, zoom, pitch, bearing, children: _, ...options } = latest.current;\n GeoMap.create(container, {\n ...stripProps(options),\n ...defined({ center, zoom, pitch, bearing }),\n ...camera,\n }).then(\n (map) => {\n // Unmounted while the engine was loading (or StrictMode's second mount): that map is not wanted\n if (cancelled) {\n map.destroy();\n return;\n }\n created = map;\n const viewsheds = new Map<object, ViewshedOptions>();\n setBinding({\n map,\n order: new LayerOrder(),\n viewsheds,\n applyViewsheds: () => map.setViewshed(viewsheds.size > 0 ? [...viewsheds.values()] : undefined),\n });\n latest.current.onLoad?.(map);\n },\n (error: unknown) => {\n if (cancelled) return;\n if (latest.current.onError) latest.current.onError(error);\n else console.error(error);\n },\n );\n return () => {\n cancelled = true;\n created?.destroy();\n setBinding(undefined);\n };\n }, []);\n\n // The events, each listened to once: the props may give another function at each render\n const map = binding?.map;\n useEffect(() => {\n if (!map) return;\n const offs = Object.entries(EVENT_PROPS).map(([prop, type]) =>\n map.on(type, (event) =>\n (latest.current[prop as keyof MapEventProps] as ((e: unknown) => void) | undefined)?.(event),\n ),\n );\n return () => {\n for (const off of offs) off();\n };\n }, [map]);\n\n // The options taken again, compared with what the map was given last\n const applied = useRef<IsardMapProps>(props);\n useEffect(() => {\n if (!map) return;\n const last = applied.current;\n applied.current = props;\n const done = new Set<(map: GeoMap, props: IsardMapProps) => void>();\n for (const [key, apply] of Object.entries(LIVE_OPTIONS)) {\n if (!apply || done.has(apply) || Object.is(last[key as keyof IsardMapProps], props[key as keyof IsardMapProps])) {\n continue;\n }\n done.add(apply);\n apply(map, props);\n }\n });\n\n const { camera } = props;\n useEffect(() => {\n if (map && camera && !sameCamera(map.getCamera(), camera)) map.setCamera(camera);\n }, [map, camera]);\n\n return createElement(\n 'div',\n { ref: element, id: props.id, className: props.className, style: props.style },\n binding ? createElement(MapContext.Provider, { value: binding }, props.children) : null,\n );\n});\n\n/** The props that are not options of the map */\nfunction stripProps(props: Partial<IsardMapProps>): GeoMapOptions {\n const options: Record<string, unknown> = { ...props };\n for (const key of [...Object.keys(EVENT_PROPS), 'onLoad', 'onError', 'id', 'className', 'style']) delete options[key];\n return options as GeoMapOptions;\n}\n\n/** The entries of an object whose value is defined (`exactOptionalPropertyTypes`) */\nfunction defined<T extends object>(object: T): { [K in keyof T]?: Exclude<T[K], undefined> } {\n return Object.fromEntries(Object.entries(object).filter(([, value]) => value !== undefined)) as {\n [K in keyof T]?: Exclude<T[K], undefined>;\n };\n}\n\n// ── Layers ──\n\nconst SwipeContext = createContext<SwipeGroup | undefined>(undefined);\n\nexport type LayerProps<P = Record<string, unknown>> = LayerSpec<P> & {\n /** Its place among the layers of the components: from the bottom up, the same order by mounting (default 0) */\n order?: number;\n /** The layer, once created and each time it is made anew */\n onLayer?: (layer: LayerHandle) => void;\n};\n\n/**\n * A layer: the options of its `add…` method with its `type` (`map.add`). A change of data, style or instances updates\n * it; a change of what is set at creation (its URL, grid, nodes…) makes it anew, in its place. Data, functions and\n * arrays are compared by identity: keep them in a memo or a state. The ref gives the layer's handle\n */\nexport const Layer = forwardRef<LayerHandle | undefined, LayerProps>(function Layer(props, ref) {\n const binding = useContext(MapContext);\n const swipe = useContext(SwipeContext);\n const { order = 0, onLayer, ...spec } = props;\n const state = useRef<{ layer: LayerHandle; spec: LayerSpec; order: number }>(undefined);\n const [layer, setLayer] = useState<LayerHandle>();\n useImperativeHandle(ref, () => layer, [layer]);\n const latest = useRef({ spec, order, onLayer });\n latest.current = { spec, order, onLayer };\n\n useEffect(() => {\n if (!binding) return;\n const { spec, order, onLayer } = latest.current;\n const created = binding.map.add(spec as LayerSpec);\n binding.order.place(created, order);\n state.current = { layer: created, spec, order };\n swipe?.set(created);\n setLayer(created);\n onLayer?.(created);\n return () => {\n const current = state.current;\n state.current = undefined;\n if (!current) return;\n binding.order.remove(current.layer);\n swipe?.unset(current.layer);\n if (binding.map.hasLayer(current.layer)) current.layer.remove();\n };\n }, [binding, swipe]);\n\n useEffect(() => {\n const current = state.current;\n if (!binding || !current) return;\n const next = spec as LayerSpec;\n const change = layerChange(current.spec, next);\n current.spec = next;\n if (change?.rebuild) {\n const old = current.layer;\n const fresh = binding.map.rebuildLayer(old, next);\n binding.order.place(fresh, order, old);\n swipe?.unset(old);\n swipe?.set(fresh);\n current.layer = fresh;\n current.order = order;\n setLayer(fresh);\n latest.current.onLayer?.(fresh);\n return;\n }\n if (change) applyLayerChange(current.layer, next, change);\n if (current.order !== order) {\n current.order = order;\n binding.order.place(current.layer, order, current.layer);\n }\n });\n\n return null;\n});\n\n// ── Markers, popups, panels ──\n\n/** The marker of a `<Marker>` around (a `<Popup>` in it opens on its click) */\nconst MarkerContext = createContext<MarkerHandle | undefined>(undefined);\n\nexport interface MarkerProps {\n lonLat: LonLat;\n /** Metres above the ground, its stem down to `base` (what it stands on: a roof, a mesh) */\n height?: number;\n base?: number;\n draggable?: boolean;\n offset?: Point;\n /** Which part of the element sits on the position (default 'bottom' for the pin, 'center' with an icon) */\n anchor?: Anchor;\n className?: string;\n /** The marker's look, in place of the default pin; the element changes with it */\n icon?: ReactNode;\n onDragStart?: (lonLat: LonLat) => void;\n onDrag?: (lonLat: LonLat) => void;\n onDragEnd?: (lonLat: LonLat) => void;\n /** A `<Popup>` opened by a click on the marker */\n children?: ReactNode;\n}\n\n/** A marker at a position, its look the default pin or the `icon` given */\nexport function Marker(props: MarkerProps): ReactNode {\n const map = useMap();\n const custom = props.icon !== undefined;\n const { anchor, className } = props;\n const element = useMemo(() => (custom ? document.createElement('div') : undefined), [custom]);\n const marker = useMemo(\n () => new MarkerHandle({ ...defined({ anchor, className, element }) }),\n [anchor, className, element],\n );\n const latest = useRef(props);\n latest.current = props;\n\n useEffect(() => {\n if (!map) return;\n marker.addTo(map);\n const offs = [\n marker.on('dragstart', (e) => latest.current.onDragStart?.(e.lonLat)),\n marker.on('drag', (e) => latest.current.onDrag?.(e.lonLat)),\n marker.on('dragend', (e) => latest.current.onDragEnd?.(e.lonLat)),\n ];\n return () => {\n for (const off of offs) off();\n marker.remove();\n };\n }, [map, marker]);\n\n const { lonLat, height = 0, base = 0, draggable = false, offset } = props;\n useLayoutEffect(() => {\n marker.setLonLat(lonLat);\n }, [marker, lonLat[0], lonLat[1]]);\n useLayoutEffect(() => {\n marker.setHeight(height, base);\n }, [marker, height, base]);\n useLayoutEffect(() => {\n marker.setDraggable(draggable);\n }, [marker, draggable]);\n useLayoutEffect(() => {\n if (offset) marker.setOffset(offset);\n }, [marker, offset?.[0], offset?.[1]]);\n\n return createElement(\n MarkerContext.Provider,\n { value: marker },\n element ? createPortal(props.icon, element) : null,\n props.children,\n );\n}\n\nexport interface PopupProps extends PopupOptions {\n /** Its position; in a `<Marker>`, the marker's */\n lonLat?: LonLat;\n /** Metres above the ground (in a `<Marker>`, the marker's) */\n height?: number;\n /** Open or closed, when the application decides; else open when mounted alone, on the marker's click in a marker */\n open?: boolean;\n onOpen?: () => void;\n /** Closed by its button, a click on the map, or the marker's click */\n onClose?: () => void;\n children?: ReactNode;\n}\n\n/** A popup of JSX content, at a position or on a `<Marker>` */\nexport function Popup(props: PopupProps): ReactNode {\n const map = useMap();\n const marker = useContext(MarkerContext);\n const { anchor, closeButton, closeOnClick, maxWidth, className } = props;\n const content = useMemo(() => document.createElement('div'), []);\n const popup = useMemo(\n () => new PopupHandle(defined({ anchor, closeButton, closeOnClick, maxWidth, className })).setDOMContent(content),\n [anchor, closeButton, closeOnClick, maxWidth, className, content],\n );\n const latest = useRef(props);\n latest.current = props;\n\n useEffect(() => {\n if (!map) return;\n const offs = [\n popup.on('open', () => latest.current.onOpen?.()),\n popup.on('close', () => latest.current.onClose?.()),\n ];\n if (marker) marker.setPopup(popup);\n return () => {\n for (const off of offs) off();\n if (marker?.getPopup() === popup) marker.setPopup(undefined);\n popup.remove();\n };\n }, [map, marker, popup]);\n\n const { lonLat, height, open, offset } = props;\n const opened = open ?? !marker;\n useLayoutEffect(() => {\n if (offset) popup.setOffset(offset);\n }, [popup, offset?.[0], offset?.[1]]);\n useLayoutEffect(() => {\n if (!map) return;\n if (lonLat) popup.setLonLat(lonLat);\n else if (marker) popup.setLonLat(marker.getLonLat());\n if (height !== undefined) popup.setHeight(height);\n if (open === undefined && marker) return;\n if (opened && !popup.isOpen()) popup.addTo(map);\n if (!opened && popup.isOpen()) popup.remove();\n }, [map, marker, popup, lonLat?.[0], lonLat?.[1], height, open, opened]);\n\n return createPortal(props.children, content);\n}\n\nexport interface PanelProps extends Omit<PanelOptions, 'element'> {\n lonLat: LonLat;\n /** What stands in 3D: a video, an iframe, a sign */\n children?: ReactNode;\n}\n\n/** JSX standing in 3D at a position, `width` metres wide, facing `heading` */\nexport function Panel(props: PanelProps): ReactNode {\n const map = useMap();\n const { className } = props;\n const element = useMemo(() => document.createElement('div'), []);\n // The width at creation: the placement is set again by the effect below\n const initialWidth = useRef(props.width);\n const panel = useMemo(\n () => new PanelHandle({ element, width: initialWidth.current, ...defined({ className }) }),\n [element, className],\n );\n\n useEffect(() => {\n if (!map) return;\n panel.addTo(map);\n return () => {\n panel.remove();\n };\n }, [map, panel]);\n\n const { lonLat, width, heading, pitch, height } = props;\n useLayoutEffect(() => {\n panel.setLonLat(lonLat);\n }, [panel, lonLat[0], lonLat[1]]);\n useLayoutEffect(() => {\n panel.setPlacement(defined({ width, heading, pitch, height }));\n }, [panel, width, heading, pitch, height]);\n // Its content may change its CSS size\n useLayoutEffect(() => {\n panel.resize();\n });\n\n return createPortal(props.children, element);\n}\n\n// ── Effects ──\n\n/** An observer's viewshed; several `<Viewshed>` are drawn together */\nexport function Viewshed(props: ViewshedOptions): ReactNode {\n const binding = useContext(MapContext);\n const key = useMemo(() => ({}), []);\n useEffect(() => {\n if (!binding) return;\n return () => {\n binding.viewsheds.delete(key);\n binding.applyViewsheds();\n };\n }, [binding, key]);\n // Numbers, strings and the position: compared by value\n const options = JSON.stringify(props);\n useEffect(() => {\n if (!binding) return;\n binding.viewsheds.set(key, JSON.parse(options) as ViewshedOptions);\n binding.applyViewsheds();\n }, [binding, key, options]);\n return null;\n}\n\ninterface SwipeGroup {\n set(layer: LayerHandle): void;\n unset(layer: LayerHandle): void;\n}\n\nexport interface SwipeProps extends Omit<SwipeOptions, 'layers'> {\n /** The `<Layer>` shown on one side of the line only */\n children?: ReactNode;\n}\n\n/** The `<Layer>` in it shown on one side of a vertical line only, at `position` CSS pixels from the left */\nexport function Swipe(props: SwipeProps): ReactNode {\n const map = useMap();\n const layers = useMemo(() => new Set<LayerHandle>(), []);\n const latest = useRef(props);\n latest.current = props;\n const group = useMemo<SwipeGroup | undefined>(() => {\n if (!map) return undefined;\n const apply = () => {\n const { position, side } = latest.current;\n map.setSwipe(layers.size > 0 ? { position, layers: [...layers], ...defined({ side }) } : undefined);\n };\n return {\n set: (layer) => {\n layers.add(layer);\n apply();\n },\n unset: (layer) => {\n layers.delete(layer);\n apply();\n },\n };\n }, [map, layers]);\n\n const { position, side } = props;\n useEffect(() => {\n if (map && layers.size > 0) map.setSwipe({ position, layers: [...layers], ...defined({ side }) });\n }, [map, layers, position, side]);\n useEffect(\n () => () => {\n map?.setSwipe(undefined);\n },\n [map],\n );\n\n return createElement(SwipeContext.Provider, { value: group }, props.children);\n}\n\nexport type { Camera, GeoMap, LayerHandle, LayerSpec, LonLat, MarkerHandle, PanelHandle, PopupHandle };\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,OAAO,EAAE,OAAO,EAAqB,MAAM,cAAe,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAyB,MAAM,kBAAmB,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,QAAQ,EAA0C,MAAM,eAAgB,CAAC;AAClF,OAAO,EAAE,KAAK,EAAsD,MAAM,YAAa,CAAC;AACxF,OAAO,EAAE,MAAM,EAAoB,MAAM,aAAc,CAAC;AACxD,OAAO,EAAE,KAAK,EAAmB,MAAM,YAAa,CAAC;AACrD,OAAO,EAAE,KAAK,EAAmB,MAAM,YAAa,CAAC;AACrD,OAAO,EAAE,KAAK,EAAmB,MAAM,YAAa,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAgB,CAAC","sourcesContent":["/**\n * Isard in React: the map, its layers, markers, popups, panels and effects as components, created when they mount,\n * updated by the least their props need and removed when they unmount.\n *\n * ```tsx\n * <IsardMap preset=\"ign-3d\" center={[2.35, 48.85]} zoom={15} style={{ height: 400 }}>\n * <Layer type=\"lines\" data={routes} color=\"#0057b8\" width={3} />\n * <Marker lonLat={[2.35, 48.85]}><Popup>Here</Popup></Marker>\n * </IsardMap>\n * ```\n */\n\nexport type { Layer as LayerHandle } from '../layers/layers.ts';\nexport type { GeoMap, LayerSpec } from '../map.ts';\nexport type { LonLat } from '../types.ts';\nexport type { Marker as MarkerHandle, Panel as PanelHandle, Popup as PopupHandle } from '../ui/overlay.ts';\nexport type { Camera } from '../wasm/isard.js';\nexport { Control, type ControlProps } from './Control.tsx';\nexport { CustomLayer, type CustomLayerProps } from './CustomLayer.tsx';\nexport { useMap, useMapEvent } from './context.ts';\nexport { IsardMap, type IsardMapProps, type MapEventProps } from './IsardMap.tsx';\nexport { Layer, type LayerHandles, type LayerProps, type LayerType } from './Layer.tsx';\nexport { Marker, type MarkerProps } from './Marker.tsx';\nexport { Panel, type PanelProps } from './Panel.tsx';\nexport { Popup, type PopupProps } from './Popup.tsx';\nexport { Swipe, type SwipeProps } from './Swipe.tsx';\nexport { Viewshed } from './Viewshed.tsx';\n"]}
|
package/dist/settings.d.ts
CHANGED
|
@@ -25,15 +25,11 @@ export interface Settings {
|
|
|
25
25
|
globeColor: [r: number, g: number, b: number];
|
|
26
26
|
}
|
|
27
27
|
/** A body from the option, its defaults filled in */
|
|
28
|
-
export declare
|
|
28
|
+
export declare const bodySettings: (body: CelestialBody | undefined) => Required<BodyOptions>;
|
|
29
29
|
/** The halo of an atmosphere for the engine (RGB 0-1 and its strength, the color's alpha): undefined for none */
|
|
30
|
-
export declare
|
|
31
|
-
|
|
32
|
-
* Terrarium PNGs decoded by `terrainLoader`) or the IGN terrain model (France, raised by the geoid); NASA's on the Moon
|
|
33
|
-
* and Mars; an ArcGIS image service asked for in the body's Mercator. `terrainLoader`: the loader of PNG tiles in an
|
|
34
|
-
* encoding, the same for the same tiles (the engine keeps its tiles when only the exaggeration changes) */
|
|
35
|
-
export declare function terrainSettings(terrain: boolean | TerrainModel | TerrainOptions | undefined, body: CelestialBody | undefined, radius: number, terrainLoader: (url: string, encoding: PngEncoding, floor?: number) => TerrainLoader): Settings['terrain'];
|
|
30
|
+
export declare const haloSettings: (atmosphere: boolean | string) => Float32Array | undefined;
|
|
31
|
+
export declare const terrainSettings: (terrain: boolean | TerrainModel | TerrainOptions | undefined, body: CelestialBody | undefined, radius: number, terrainLoader: (url: string, encoding: PngEncoding, floor?: number) => TerrainLoader) => Settings["terrain"];
|
|
36
32
|
/** Sky settings for the engine: colors (RGB 0-1) and blends, MapLibre's defaults */
|
|
37
|
-
export declare
|
|
33
|
+
export declare const atmosphereSettings: (options: AtmosphereOptions | undefined) => Float32Array | undefined;
|
|
38
34
|
/** A CSS color to RGB 0-1 (its alpha dropped); black if unknown */
|
|
39
|
-
export declare
|
|
35
|
+
export declare const rgb: (color: string) => [r: number, g: number, b: number];
|
package/dist/settings.js
CHANGED
|
@@ -21,31 +21,33 @@ const BODIES = {
|
|
|
21
21
|
/** The Earth's halo, RGB 0-1 and its strength: what `atmosphere: true` draws */
|
|
22
22
|
const EARTH_HALO = Float32Array.of(0.42, 0.66, 1, 1);
|
|
23
23
|
/** A body from the option, its defaults filled in */
|
|
24
|
-
export
|
|
24
|
+
export const bodySettings = (body) => {
|
|
25
25
|
if (body === undefined || typeof body === 'string')
|
|
26
26
|
return BODIES[body ?? 'earth'];
|
|
27
27
|
const relief = [-0.01 * body.radius, 0.01 * body.radius];
|
|
28
28
|
return { flattening: 0, atmosphere: false, color: '#808080', relief, ...body };
|
|
29
|
-
}
|
|
29
|
+
};
|
|
30
30
|
/** The halo of an atmosphere for the engine (RGB 0-1 and its strength, the color's alpha): undefined for none */
|
|
31
|
-
export
|
|
31
|
+
export const haloSettings = (atmosphere) => {
|
|
32
32
|
if (atmosphere === true)
|
|
33
33
|
return EARTH_HALO;
|
|
34
34
|
const color = atmosphere === false ? undefined : parseCssColor(atmosphere);
|
|
35
35
|
return color && Float32Array.from(color);
|
|
36
|
-
}
|
|
36
|
+
};
|
|
37
37
|
/** Relief settings from the option: undefined when off. On the Earth the Terrain Tiles by default (worldwide,
|
|
38
38
|
* Terrarium PNGs decoded by `terrainLoader`) or the IGN terrain model (France, raised by the geoid); NASA's on the Moon
|
|
39
39
|
* and Mars; an ArcGIS image service asked for in the body's Mercator. `terrainLoader`: the loader of PNG tiles in an
|
|
40
40
|
* encoding, the same for the same tiles (the engine keeps its tiles when only the exaggeration changes) */
|
|
41
|
-
|
|
41
|
+
/** The relief options of the option on */
|
|
42
|
+
const terrainOptions = (terrain) => {
|
|
43
|
+
if (typeof terrain === 'string')
|
|
44
|
+
return { model: terrain };
|
|
45
|
+
return terrain === true ? {} : terrain;
|
|
46
|
+
};
|
|
47
|
+
export const terrainSettings = (terrain, body, radius, terrainLoader) => {
|
|
42
48
|
if (!terrain)
|
|
43
49
|
return undefined;
|
|
44
|
-
|
|
45
|
-
if (typeof terrain === 'string')
|
|
46
|
-
options = { model: terrain };
|
|
47
|
-
else if (terrain !== true)
|
|
48
|
-
options = terrain;
|
|
50
|
+
const options = terrainOptions(terrain);
|
|
49
51
|
const earth = (body ?? 'earth') === 'earth';
|
|
50
52
|
const exaggeration = options.exaggeration ?? 1;
|
|
51
53
|
if (options.url === undefined && earth) {
|
|
@@ -82,9 +84,9 @@ export function terrainSettings(terrain, body, radius, terrainLoader) {
|
|
|
82
84
|
// NASA's credits for its models
|
|
83
85
|
...(options.url === undefined && preset ? { attribution: preset.attribution } : {}),
|
|
84
86
|
};
|
|
85
|
-
}
|
|
87
|
+
};
|
|
86
88
|
/** Sky settings for the engine: colors (RGB 0-1) and blends, MapLibre's defaults */
|
|
87
|
-
export
|
|
89
|
+
export const atmosphereSettings = (options) => {
|
|
88
90
|
if (!options)
|
|
89
91
|
return undefined;
|
|
90
92
|
return Float32Array.from([
|
|
@@ -95,10 +97,10 @@ export function atmosphereSettings(options) {
|
|
|
95
97
|
options.horizonFogBlend ?? 0.7,
|
|
96
98
|
options.fogGroundBlend ?? 0.4,
|
|
97
99
|
]);
|
|
98
|
-
}
|
|
100
|
+
};
|
|
99
101
|
/** A CSS color to RGB 0-1 (its alpha dropped); black if unknown */
|
|
100
|
-
export
|
|
102
|
+
export const rgb = (color) => {
|
|
101
103
|
const [r, g, b] = parseCssColor(color) ?? [0, 0, 0, 1];
|
|
102
104
|
return [r, g, b];
|
|
103
|
-
}
|
|
105
|
+
};
|
|
104
106
|
//# sourceMappingURL=settings.js.map
|
package/dist/settings.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,aAAa,EACb,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,yBAAyB,EACzB,WAAW,GACZ,MAAM,uBAAuB,CAAC;AAU/B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AA8BhD;;mGAEmG;AACnG,MAAM,MAAM,GAAuE;IACjF,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,GAAG,aAAa,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE;IACnH,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE;IACrG,IAAI,EAAE;QACJ,MAAM,EAAE,OAAO;QACf,UAAU,EAAE,CAAC;QACb,UAAU,EAAE,0BAA0B;QACtC,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC;KACvB;CACF,CAAC;AAEF,gFAAgF;AAChF,MAAM,UAAU,GAAG,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAErD,qDAAqD;AACrD,MAAM,UAAU,YAAY,CAAC,IAA+B;IAC1D,IAAI,IAAI,KAAK,SAAS,IAAI,OAAO,IAAI,KAAK,QAAQ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,CAAC,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACvD,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACnB,CAAC","sourcesContent":["/**\n * The settings of a map's engine from its options: the body, its halo, its relief, the sky. Kept by the map and\n * replayed on a new engine (after a context loss, or on the engine with 3D Tiles).\n */\nimport {\n BODY_TERRAINS,\n IGN_ATTRIBUTION,\n IMAGE_SERVER,\n imageServerTerrain,\n TERRAIN_TILES,\n TERRAIN_TILES_ATTRIBUTION,\n TERRAIN_URL,\n} from './basemap/basemaps.ts';\nimport type { PngEncoding } from './basemap/terrain.ts';\nimport type {\n AtmosphereOptions,\n BodyOptions,\n CelestialBody,\n LoadingMode,\n TerrainModel,\n TerrainOptions,\n} from './types.ts';\nimport { parseCssColor } from './util/color.ts';\n\n/** Decodes the relief tiles of a URL for the engine: 256 × 256 altitudes, null where there is no tile */\nexport type TerrainLoader = (z: number, x: number, y: number, signal: AbortSignal) => Promise<Float32Array | null>;\n\n/** Settings replayed on a new engine after a WebGL context loss */\nexport interface Settings {\n body: Required<BodyOptions>;\n zoomRange: [min: number, max: number];\n maxPitch: number;\n globe: boolean;\n sky: boolean;\n atmosphere: Float32Array | undefined;\n terrain:\n | {\n url: string;\n exaggeration: number;\n maxZoom: number;\n geoid: boolean;\n /** Decodes the tiles of `url` for the engine (an encoding other than raw floats) */\n loader?: TerrainLoader;\n /** Credits of the model */\n attribution?: string;\n }\n | undefined;\n loading: LoadingMode;\n background: [r: number, g: number, b: number];\n globeColor: [r: number, g: number, b: number];\n}\n\n/** The named bodies; a body's `color` is that of its globe under the tiles (the Earth's follows its basemap), its\n * `relief` the range of its ground (the Earth's dry land, from the Dead Sea to Everest). Mars: the sphere of its\n * equatorial radius (its data take planetocentric latitudes), a faint butterscotch halo of dust */\nconst BODIES: Record<Exclude<CelestialBody, BodyOptions>, Required<BodyOptions>> = {\n earth: { radius: 6378137, flattening: 1 / 298.257223563, atmosphere: true, color: '#cacaca', relief: [-450, 8900] },\n moon: { radius: 1737400, flattening: 0, atmosphere: false, color: '#77756f', relief: [-9200, 10800] },\n mars: {\n radius: 3396190,\n flattening: 0,\n atmosphere: 'rgba(232, 168, 120, 0.6)',\n color: '#b5714a',\n relief: [-8300, 21300],\n },\n};\n\n/** The Earth's halo, RGB 0-1 and its strength: what `atmosphere: true` draws */\nconst EARTH_HALO = Float32Array.of(0.42, 0.66, 1, 1);\n\n/** A body from the option, its defaults filled in */\nexport function bodySettings(body: CelestialBody | undefined): Required<BodyOptions> {\n if (body === undefined || typeof body === 'string') return BODIES[body ?? 'earth'];\n const relief: [number, number] = [-0.01 * body.radius, 0.01 * body.radius];\n return { flattening: 0, atmosphere: false, color: '#808080', relief, ...body };\n}\n\n/** The halo of an atmosphere for the engine (RGB 0-1 and its strength, the color's alpha): undefined for none */\nexport function haloSettings(atmosphere: boolean | string): Float32Array | undefined {\n if (atmosphere === true) return EARTH_HALO;\n const color = atmosphere === false ? undefined : parseCssColor(atmosphere);\n return color && Float32Array.from(color);\n}\n\n/** Relief settings from the option: undefined when off. On the Earth the Terrain Tiles by default (worldwide,\n * Terrarium PNGs decoded by `terrainLoader`) or the IGN terrain model (France, raised by the geoid); NASA's on the Moon\n * and Mars; an ArcGIS image service asked for in the body's Mercator. `terrainLoader`: the loader of PNG tiles in an\n * encoding, the same for the same tiles (the engine keeps its tiles when only the exaggeration changes) */\nexport function terrainSettings(\n terrain: boolean | TerrainModel | TerrainOptions | undefined,\n body: CelestialBody | undefined,\n radius: number,\n terrainLoader: (url: string, encoding: PngEncoding, floor?: number) => TerrainLoader,\n): Settings['terrain'] {\n if (!terrain) return undefined;\n let options: TerrainOptions = {};\n if (typeof terrain === 'string') options = { model: terrain };\n else if (terrain !== true) options = terrain;\n const earth = (body ?? 'earth') === 'earth';\n const exaggeration = options.exaggeration ?? 1;\n if (options.url === undefined && earth) {\n if (options.model === 'ign') {\n const geoid = options.geoid ?? true;\n return { url: TERRAIN_URL, exaggeration, maxZoom: options.maxZoom ?? 15, geoid, attribution: IGN_ATTRIBUTION };\n }\n return {\n url: TERRAIN_TILES.url,\n exaggeration,\n maxZoom: options.maxZoom ?? TERRAIN_TILES.maxZoom,\n geoid: options.geoid ?? false,\n // The sea floor of the model at sea level: the oceans stay flat under the basemap's water\n loader: terrainLoader(TERRAIN_TILES.url, 'terrarium', 0),\n attribution: TERRAIN_TILES_ATTRIBUTION,\n };\n }\n const preset = body === 'moon' || body === 'mars' ? BODY_TERRAINS[body] : undefined;\n const url = options.url ?? preset?.url;\n if (url === undefined) throw new Error('isard: the relief of this body needs a url');\n const encoding = options.encoding ?? 'float32';\n // PNG encodings are fetched tile by tile: a {bbox} or an image service would be fetched as it is\n if (\n encoding !== 'float32' &&\n (IMAGE_SERVER.test(url) || !/\\{z\\}/.test(url) || !/\\{x\\}/.test(url) || !/\\{y\\}/.test(url))\n ) {\n throw new Error(`isard: the '${encoding}' terrain encoding takes a tile URL with {z}, {x} and {y} (${url})`);\n }\n return {\n url: IMAGE_SERVER.test(url) ? imageServerTerrain(url, earth, radius) : url,\n exaggeration,\n maxZoom: options.maxZoom ?? (options.url === undefined && preset ? preset.maxZoom : 15),\n geoid: options.geoid ?? false,\n ...(encoding === 'float32' ? {} : { loader: terrainLoader(url, encoding) }),\n // NASA's credits for its models\n ...(options.url === undefined && preset ? { attribution: preset.attribution } : {}),\n };\n}\n\n/** Sky settings for the engine: colors (RGB 0-1) and blends, MapLibre's defaults */\nexport function atmosphereSettings(options: AtmosphereOptions | undefined): Float32Array | undefined {\n if (!options) return undefined;\n return Float32Array.from([\n ...rgb(options.skyColor ?? '#9cc7ec'),\n ...rgb(options.horizonColor ?? '#e8f1f8'),\n ...rgb(options.fogColor ?? '#f2f5f8'),\n options.skyHorizonBlend ?? 0.6,\n options.horizonFogBlend ?? 0.7,\n options.fogGroundBlend ?? 0.4,\n ]);\n}\n\n/** A CSS color to RGB 0-1 (its alpha dropped); black if unknown */\nexport function rgb(color: string): [r: number, g: number, b: number] {\n const [r, g, b] = parseCssColor(color) ?? [0, 0, 0, 1];\n return [r, g, b];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,aAAa,EACb,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,yBAAyB,EACzB,WAAW,GACZ,MAAM,uBAAuB,CAAC;AAU/B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AA8BhD;;mGAEmG;AACnG,MAAM,MAAM,GAAuE;IACjF,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,GAAG,aAAa,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE;IACnH,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE;IACrG,IAAI,EAAE;QACJ,MAAM,EAAE,OAAO;QACf,UAAU,EAAE,CAAC;QACb,UAAU,EAAE,0BAA0B;QACtC,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC;KACvB;CACF,CAAC;AAEF,gFAAgF;AAChF,MAAM,UAAU,GAAG,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAErD,qDAAqD;AACrD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAA+B,EAAyB,EAAE;IACrF,IAAI,IAAI,KAAK,SAAS,IAAI,OAAO,IAAI,KAAK,QAA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CAAC,eAAe,IAAI,GAAG;QAC9B,OAAO,CAAC,eAAe,IAAI,GAAG;QAC9B,OAAO,CAAC,cAAc,IAAI,GAAG;KAC9B,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,mEAAmE;AACnE,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,KAAa,EAAqC,EAAE;IACtE,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAEvD,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACnB,CAAC,CAAC","sourcesContent":["/**\n * The settings of a map's engine from its options: the body, its halo, its relief, the sky. Kept by the map and\n * replayed on a new engine (after a context loss, or on the engine with 3D Tiles).\n */\nimport {\n BODY_TERRAINS,\n IGN_ATTRIBUTION,\n IMAGE_SERVER,\n imageServerTerrain,\n TERRAIN_TILES,\n TERRAIN_TILES_ATTRIBUTION,\n TERRAIN_URL,\n} from './basemap/basemaps.ts';\nimport type { PngEncoding } from './basemap/terrain.ts';\nimport type {\n AtmosphereOptions,\n BodyOptions,\n CelestialBody,\n LoadingMode,\n TerrainModel,\n TerrainOptions,\n} from './types.ts';\nimport { parseCssColor } from './util/color.ts';\n\n/** Decodes the relief tiles of a URL for the engine: 256 × 256 altitudes, null where there is no tile */\nexport type TerrainLoader = (z: number, x: number, y: number, signal: AbortSignal) => Promise<Float32Array | null>;\n\n/** Settings replayed on a new engine after a WebGL context loss */\nexport interface Settings {\n body: Required<BodyOptions>;\n zoomRange: [min: number, max: number];\n maxPitch: number;\n globe: boolean;\n sky: boolean;\n atmosphere: Float32Array | undefined;\n terrain:\n | {\n url: string;\n exaggeration: number;\n maxZoom: number;\n geoid: boolean;\n /** Decodes the tiles of `url` for the engine (an encoding other than raw floats) */\n loader?: TerrainLoader;\n /** Credits of the model */\n attribution?: string;\n }\n | undefined;\n loading: LoadingMode;\n background: [r: number, g: number, b: number];\n globeColor: [r: number, g: number, b: number];\n}\n\n/** The named bodies; a body's `color` is that of its globe under the tiles (the Earth's follows its basemap), its\n * `relief` the range of its ground (the Earth's dry land, from the Dead Sea to Everest). Mars: the sphere of its\n * equatorial radius (its data take planetocentric latitudes), a faint butterscotch halo of dust */\nconst BODIES: Record<Exclude<CelestialBody, BodyOptions>, Required<BodyOptions>> = {\n earth: { radius: 6378137, flattening: 1 / 298.257223563, atmosphere: true, color: '#cacaca', relief: [-450, 8900] },\n moon: { radius: 1737400, flattening: 0, atmosphere: false, color: '#77756f', relief: [-9200, 10800] },\n mars: {\n radius: 3396190,\n flattening: 0,\n atmosphere: 'rgba(232, 168, 120, 0.6)',\n color: '#b5714a',\n relief: [-8300, 21300],\n },\n};\n\n/** The Earth's halo, RGB 0-1 and its strength: what `atmosphere: true` draws */\nconst EARTH_HALO = Float32Array.of(0.42, 0.66, 1, 1);\n\n/** A body from the option, its defaults filled in */\nexport const bodySettings = (body: CelestialBody | undefined): Required<BodyOptions> => {\n if (body === undefined || typeof body === 'string') return BODIES[body ?? 'earth'];\n\n const relief: [number, number] = [-0.01 * body.radius, 0.01 * body.radius];\n\n return { flattening: 0, atmosphere: false, color: '#808080', relief, ...body };\n};\n\n/** The halo of an atmosphere for the engine (RGB 0-1 and its strength, the color's alpha): undefined for none */\nexport const haloSettings = (atmosphere: boolean | string): Float32Array | undefined => {\n if (atmosphere === true) return EARTH_HALO;\n\n const color = atmosphere === false ? undefined : parseCssColor(atmosphere);\n\n return color && Float32Array.from(color);\n};\n\n/** Relief settings from the option: undefined when off. On the Earth the Terrain Tiles by default (worldwide,\n * Terrarium PNGs decoded by `terrainLoader`) or the IGN terrain model (France, raised by the geoid); NASA's on the Moon\n * and Mars; an ArcGIS image service asked for in the body's Mercator. `terrainLoader`: the loader of PNG tiles in an\n * encoding, the same for the same tiles (the engine keeps its tiles when only the exaggeration changes) */\n/** The relief options of the option on */\nconst terrainOptions = (terrain: true | TerrainModel | TerrainOptions): TerrainOptions => {\n if (typeof terrain === 'string') return { model: terrain };\n\n return terrain === true ? {} : terrain;\n};\n\nexport const terrainSettings = (\n terrain: boolean | TerrainModel | TerrainOptions | undefined,\n body: CelestialBody | undefined,\n radius: number,\n terrainLoader: (url: string, encoding: PngEncoding, floor?: number) => TerrainLoader,\n): Settings['terrain'] => {\n if (!terrain) return undefined;\n\n const options = terrainOptions(terrain);\n const earth = (body ?? 'earth') === 'earth';\n const exaggeration = options.exaggeration ?? 1;\n\n if (options.url === undefined && earth) {\n if (options.model === 'ign') {\n const geoid = options.geoid ?? true;\n\n return { url: TERRAIN_URL, exaggeration, maxZoom: options.maxZoom ?? 15, geoid, attribution: IGN_ATTRIBUTION };\n }\n\n return {\n url: TERRAIN_TILES.url,\n exaggeration,\n maxZoom: options.maxZoom ?? TERRAIN_TILES.maxZoom,\n geoid: options.geoid ?? false,\n // The sea floor of the model at sea level: the oceans stay flat under the basemap's water\n loader: terrainLoader(TERRAIN_TILES.url, 'terrarium', 0),\n attribution: TERRAIN_TILES_ATTRIBUTION,\n };\n }\n\n const preset = body === 'moon' || body === 'mars' ? BODY_TERRAINS[body] : undefined;\n const url = options.url ?? preset?.url;\n\n if (url === undefined) throw new Error('isard: the relief of this body needs a url');\n\n const encoding = options.encoding ?? 'float32';\n\n // PNG encodings are fetched tile by tile: a {bbox} or an image service would be fetched as it is\n if (\n encoding !== 'float32' &&\n (IMAGE_SERVER.test(url) || !/\\{z\\}/.test(url) || !/\\{x\\}/.test(url) || !/\\{y\\}/.test(url))\n ) {\n throw new Error(`isard: the '${encoding}' terrain encoding takes a tile URL with {z}, {x} and {y} (${url})`);\n }\n\n return {\n url: IMAGE_SERVER.test(url) ? imageServerTerrain(url, earth, radius) : url,\n exaggeration,\n maxZoom: options.maxZoom ?? (options.url === undefined && preset ? preset.maxZoom : 15),\n geoid: options.geoid ?? false,\n ...(encoding === 'float32' ? {} : { loader: terrainLoader(url, encoding) }),\n // NASA's credits for its models\n ...(options.url === undefined && preset ? { attribution: preset.attribution } : {}),\n };\n};\n\n/** Sky settings for the engine: colors (RGB 0-1) and blends, MapLibre's defaults */\nexport const atmosphereSettings = (options: AtmosphereOptions | undefined): Float32Array | undefined => {\n if (!options) return undefined;\n\n return Float32Array.from([\n ...rgb(options.skyColor ?? '#9cc7ec'),\n ...rgb(options.horizonColor ?? '#e8f1f8'),\n ...rgb(options.fogColor ?? '#f2f5f8'),\n options.skyHorizonBlend ?? 0.6,\n options.horizonFogBlend ?? 0.7,\n options.fogGroundBlend ?? 0.4,\n ]);\n};\n\n/** A CSS color to RGB 0-1 (its alpha dropped); black if unknown */\nexport const rgb = (color: string): [r: number, g: number, b: number] => {\n const [r, g, b] = parseCssColor(color) ?? [0, 0, 0, 1];\n\n return [r, g, b];\n};\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -376,11 +376,11 @@ export interface LayerHost {
|
|
|
376
376
|
readonly engine: Engine;
|
|
377
377
|
requestRender(): void;
|
|
378
378
|
/** Forgets a removed layer */
|
|
379
|
-
detach(layer:
|
|
379
|
+
detach(layer: Layer): void;
|
|
380
380
|
/** Moves a layer under `before`, or on top */
|
|
381
|
-
moveLayer(layer:
|
|
381
|
+
moveLayer(layer: Layer, before: Layer | undefined): void;
|
|
382
382
|
/** A layer created again in the engine (new id): put at the place of its old id, which is removed */
|
|
383
|
-
replaceLayer(layer:
|
|
383
|
+
replaceLayer(layer: Layer, old: number): void;
|
|
384
384
|
/** Resolves once the map is idle (everything in view loaded and drawn) */
|
|
385
385
|
whenIdle(): Promise<void>;
|
|
386
386
|
}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,0CAA0C","sourcesContent":["/** Public types of the `isard` package */\n\nimport type { TileGrid } from './basemap/grid.ts';\nimport type { DecoderUrls } from './engine/decoders.ts';\nimport type { Feature, Ramp, Size } from './layers/features.ts';\nimport type { Layer } from './layers/layers.ts';\nimport type { AttributionOptions } from './ui/controls.ts';\nimport type { Camera, Engine } from './wasm/isard.js';\n\nexport type LonLat = [lon: number, lat: number];\nexport type Point = [x: number, y: number];\n\n/**\n * The named basemaps. OpenFreeMap's vector styles, OpenStreetMap data worldwide, their labels above the other layers:\n * `osm-positron` (light grey, quiet: data over it reads first), `osm-liberty` and `osm-bright` (in colour). The\n * Géoplateforme's (IGN, France): rasters (`ign-plan`, `ign-plan-grey`, `ign-ortho`, the aerial photographs) or vector\n * tiles with their labels (`ign-plan-vector`, `ign-plan-grey-vector`, the PLAN.IGN styles).\n */\nexport type BasemapName =\n | 'osm-positron'\n | 'osm-liberty'\n | 'osm-bright'\n | 'ign-plan'\n | 'ign-plan-grey'\n | 'ign-ortho'\n | 'ign-plan-vector'\n | 'ign-plan-grey-vector'\n | 'none';\n\n/** A basemap by name (see `BasemapName`) */\nexport type Basemap = BasemapName;\n\n/**\n * The Earth's named terrain models. `'terrain-tiles'`: worldwide, the Terrain Tiles of AWS's open data registry\n * (SRTM, EU-DEM, GMTED… merged by Mapzen, 30 m in most places), the sea floor flattened at sea level. `'ign'`: France,\n * the IGN's RGE ALTI from the Géoplateforme (1 to 5 m), raised by the RAF20 geoid to heights above the ellipsoid.\n */\nexport type TerrainModel = 'terrain-tiles' | 'ign';\n\n/** How tiles encode their altitudes: `'float32'`, raw little-endian floats (`image/x-bil;bits=32`, an ArcGIS raw\n * grid); `'terrarium'`, the colors of a PNG, `R × 256 + G + B / 256 - 32768`; `'mapbox'`, those of Terrain-RGB,\n * `(R × 65536 + G × 256 + B) / 10 - 10000` */\nexport type TerrainEncoding = 'float32' | 'terrarium' | 'mapbox';\n\n/**\n * How tiles load and show. 'immediate' (default): everything visible loads, tiles show as soon as they arrive.\n * 'smooth': during flights the levels flown through are skipped, off-center tiles wait while the camera moves, tiles\n * fade in; fewer downloads, for slow networks or GPUs.\n */\nexport type LoadingMode = 'immediate' | 'smooth';\n\n/** 'globe': a sphere at low zoom, blending into Web Mercator between zooms 5 and 7, up to three levels later under a\n * tilted camera (it sees much farther than its center: the horizon stays curved) */\nexport type Projection = 'globe' | 'mercator';\n\n/** A body to draw the map on, other than the named ones (`CelestialBody`) */\nexport interface BodyOptions {\n /** Equatorial radius, metres */\n radius: number;\n /** Flattening of its ellipsoid, 0 for a sphere (default 0) */\n flattening?: number;\n /** An atmosphere: its halo around the globe, true for the Earth's light blue, or a CSS color (its alpha the\n * halo's strength) (default false) */\n atmosphere?: boolean | string;\n /** Color of the globe where no tile covers it (past the Web Mercator latitudes, 85°), a CSS color (default\n * `#808080`) */\n color?: string;\n /** Lowest and highest altitudes of its ground, metres around the ellipsoid: what its relief may raise into view\n * (default ±1 % of the radius) */\n relief?: [lowest: number, highest: number];\n}\n\n/**\n * The body the map is drawn on: 'earth' (WGS 84, the default), 'moon' (a sphere of 1 737 400 m, no atmosphere),\n * 'mars' (a sphere of 3 396 190 m, its equatorial radius, a thin dusty halo; planetocentric latitudes) or another\n * one. Zoom levels keep their meaning on screen (the Web Mercator tile pyramid), their metres follow the body:\n * altitudes, relief, buildings, 3D Tiles. Off the Earth, the map has none of the Earth's defaults: no basemap, no\n * credits, and space for its background; the Moon and Mars have NASA's relief for `terrain: true`.\n */\nexport type CelestialBody = 'earth' | 'moon' | 'mars' | BodyOptions;\n\nexport interface GeoMapOptions extends Partial<Camera> {\n /** The body the map is drawn on (default 'earth'); set at creation */\n body?: CelestialBody;\n /** Default 'globe' */\n projection?: Projection;\n /** Default 'immediate' */\n loading?: LoadingMode;\n /** The basemap (default 'osm-positron'; 'none' off the Earth) */\n basemap?: Basemap;\n /** Opacity of the IGN hillshade over the basemap (France, Géoplateforme), 0 for none (default 0) */\n hillshade?: number;\n /** Color behind the map (sky of tilted flat views), a CSS color (default `#f2f2f0`; black off the Earth) */\n background?: string;\n /** Space behind the globe: stars and atmosphere halo, fading out as the globe turns flat (default true) */\n sky?: boolean;\n /** Relief under the basemap: true for the body's terrain model (on the Earth the worldwide Terrain Tiles; NASA's on\n * the Moon and Mars: LOLA, MOLA), one of the Earth's models by name (`'ign'`: France, RGE ALTI), or its options\n * (default false; on another body, its `url` is required). Network layers are draped on it */\n terrain?: boolean | TerrainModel | TerrainOptions;\n minZoom?: number;\n maxZoom?: number;\n /** Highest pitch, degrees, up to 85 (default 70) */\n maxPitch?: number;\n /** Sky over the plane, seen when the camera is tilted towards the horizon, and the fog the ground fades into\n * (MapLibre's `setSky`); default none: the background color */\n atmosphere?: AtmosphereOptions;\n /** Mouse, touch and keyboard controls (default true) */\n interactive?: boolean;\n /** Keyboard controls once the map has the focus (it is reached with Tab): arrows pan, Shift + arrows rotate and\n * tilt, + and - zoom (Shift: two levels), 0 faces north and levels the view (default true; none when not\n * `interactive`) */\n keyboard?: boolean;\n /** Accessible name of the map, read by screen readers (default 'Map') */\n ariaLabel?: string;\n /** A preset of map options (`IGN_PRESETS`: `'ign'`, `'ign-3d'`, `'ign-ortho-3d'`), the other options over it */\n preset?: 'ign' | 'ign-3d' | 'ign-ortho-3d';\n /** The folder isard's files are served from (its engines, `isard_bg.wasm`, `isard_core_bg.wasm`,\n * `isard_points_bg.wasm`, and its workers, `decoder.worker.js`, `basemap.worker.js`): one option for a bundler that\n * moves them, the `…Url` options below for each one. `isard/vite` sets it for the whole page; default next to the\n * module */\n assetsUrl?: string | URL;\n /** Where to load the engine with 3D Tiles from (`isard_bg.wasm`), when a bundler does not resolve the default URL.\n * Given without `coreWasmUrl`, maps load this engine from the start */\n wasmUrl?: string | URL;\n /** Where to load the engine without 3D Tiles from (`isard_core_bg.wasm`, a third smaller), when a bundler does not\n * resolve the default URL. Maps load it first, and the engine with 3D Tiles (`wasmUrl`) for their first 3D Tiles\n * layer only */\n coreWasmUrl?: string | URL;\n /** Where the decoding workers load the point cloud module from (`isard_points_bg.wasm`, the LAZ decoder of COPC),\n * when a bundler does not resolve the default URL. Loaded with the first point cloud only */\n pointsWasmUrl?: string | URL;\n /** Load the engine with 3D Tiles from the start (default false: it is loaded when the first 3D Tiles layer or glTF\n * model is added, the map then moving its camera and layers onto it, a stall of about a frame or two). For a map that shows 3D Tiles\n * at once: one engine downloaded instead of two. `'preload'`: the map starts on the engine without 3D Tiles and\n * downloads and compiles the other once idle, without running it: its first 3D Tiles layer does not wait for the\n * download (for a map that will show 3D Tiles later, on demand) */\n tiles3d?: boolean | 'preload';\n /** Where to load the vector basemap worker from, when a bundler does not resolve the default URL */\n basemapWorkerUrl?: string | URL;\n /** Texture size of the vector basemap's tiles, pixels (default 512: lines and edges sharp at every zoom on a screen\n * of pixel ratio 1). 256: a quarter of the drawing in the workers, of the uploads and of the GPU memory, for lines\n * and edges a little softer between two zoom levels (the tiles are shown 181 to 362 CSS pixels wide) */\n basemapTileSize?: number;\n /** Glyphs of the symbol layers: a URL with `{fontstack}` and `{range}` (MapLibre's glyph format; default\n * OpenFreeMap's fonts, Noto Sans). A vector basemap's labels take the glyphs of its style */\n glyphs?: string;\n /** Workers decoding 3D Tiles off the main thread: a count, or false to decode on the main thread (default: cores - 1,\n * 1 to 4). False (or 0) also decodes the PNG relief and reprojects the equirectangular rasters on the main thread,\n * else done by the vector basemap's workers */\n workers?: number | false;\n /** Where to load the decoding worker from, when a bundler does not resolve the default URL */\n workerUrl?: string | URL;\n /** Folders of the Draco and Basis Universal decoders, loaded by the workers on first use (default: the official\n * builds on gstatic.com and jsDelivr; self-host them for offline or locked-down networks). They run through\n * `new Function`: a Content Security Policy needs `'unsafe-eval'` (see `DecoderUrls`) */\n decoders?: Partial<DecoderUrls>;\n /** Credits at the bottom right: false for none, or its options (default true: the credits of the basemap,\n * hillshade and relief in use, compact on maps narrower than 640 px) */\n attributionControl?: boolean | AttributionOptions;\n}\n\nexport interface TerrainOptions {\n /** One of the Earth's named models (default `'terrain-tiles'` on the Earth); unused with a `url` */\n model?: TerrainModel;\n /** Altitudes of 256 × 256 tiles in `encoding`: a WMS GetMap URL with {bbox} (EPSG:3857 on the Earth, the body's\n * Mercator metres elsewhere: the sphere of its radius), a tile URL with {z}, {x} and {y}, or an ArcGIS image service\n * (a URL ending in `/ImageServer`), asked for raw altitudes in the body's Mercator (default: the `model`'s; on the\n * Moon and Mars, NASA's Trek LOLA and MOLA models) */\n url?: string;\n /** How the tiles of `url` encode their altitudes (default `'float32'`); `'terrarium'` and `'mapbox'` take a URL with\n * {z}, {x} and {y} */\n encoding?: TerrainEncoding;\n /** Vertical exaggeration, 1 for the true relief (default 1) */\n exaggeration?: number;\n /** Finest level of the relief, up to 15 (default 15; 14 for the Terrain Tiles, 8 for the Moon's and Mars's models). It\n * starts at level 6 on the Earth, coarser on bodies of a larger relief for their size (3 on the Moon and Mars) */\n maxZoom?: number;\n /** Altitudes over mainland France raised by the height of the RAF20 geoid (the French one, 0 away from France), to\n * heights above the ellipsoid (those of 3D Tiles); false keeps the altitudes as served (NGF-IGN69 for the IGN's)\n * (default true for the `'ign'` model, false otherwise) */\n geoid?: boolean;\n}\n\n/** Sky, horizon and fog over the plane, with the names and meanings of MapLibre's `setSky` */\nexport interface AtmosphereOptions {\n /** A CSS color (default `#9cc7ec`) */\n skyColor?: string;\n /** (default `#e8f1f8`) */\n horizonColor?: string;\n /** (default `#f2f5f8`) */\n fogColor?: string;\n /** Blend from the horizon to the sky color, share of the field of view above the horizon, 0-1 (default 0.6) */\n skyHorizonBlend?: number;\n /** Blend from the horizon to the fog color below the horizon, 0-1 (default 0.7) */\n horizonFogBlend?: number;\n /** Share of the distance to the far plane over which the ground fades into the fog, 0-1 (default 0.4) */\n fogGroundBlend?: number;\n}\n\n/** What can be seen from a point (`GeoMap.setViewshed`); with several observers, the colors, the opacity and the\n * cone's color are the first one's */\nexport interface ViewshedOptions {\n /** The observer */\n position: LonLat;\n /** Metres above the ground (default 1.7, eye level) */\n height?: number;\n /** Metres around the observer that are tinted (default 1000) */\n range?: number;\n /** A CSS color for what is seen (default `#2f9e44`) */\n visibleColor?: string;\n /** A CSS color for what is hidden (default `#e03131`) */\n hiddenColor?: string;\n /** How strongly the colors tint the scene, multiplied into it so that its textures and shading stay, 0-1 (default\n * 0.7) */\n opacity?: number;\n /** A CSS color for the cone drawn in 3D (one way only): its fan through the axis, at the eye's height and tilted\n * with it, from the eye to the range; solid where nothing hides it, faint behind the scene; none by default */\n coneColor?: string;\n /** To look one way only (a camera, a lookout), degrees clockwise from north; all around without it */\n direction?: number;\n /** Degrees above the horizon the cone looks, negative below (default 0) */\n tilt?: number;\n /** Angle of view across, degrees (default 60) */\n fov?: number;\n /** Angle of view up and down, degrees (default 40) */\n verticalFov?: number;\n}\n\n/** An eye at street level (`GeoMap.setFirstPerson`) */\nexport interface FirstPersonView {\n /** Where it stands */\n lonLat: LonLat;\n /** Metres above the ground (default 1.7) */\n height?: number;\n /** Degrees clockwise from north it looks to */\n bearing: number;\n /** Degrees from straight down: 90 level (the default), 180 straight up */\n pitch?: number;\n /** Vertical field of view, degrees (default 75) */\n fov?: number;\n}\n\n/** Layers shown on one side of a vertical line only (`GeoMap.setSwipe`) */\nexport interface SwipeOptions {\n /** CSS pixels from the left of the map */\n position: number;\n layers: readonly Layer[];\n /** The side they show on (default 'left') */\n side?: 'left' | 'right';\n}\n\n/** Animation of a camera move */\nexport interface AnimationOptions {\n /** Milliseconds */\n duration?: number;\n /** Progress over time, both 0 to 1 */\n easing?: (t: number) => number;\n}\n\nexport interface FlyToOptions extends AnimationOptions {\n /** How far the flight zooms out on its way, as MapLibre's `curve` (default 1.42) */\n curve?: number;\n /** Average speed in screens per second when `duration` is not given (default 1.2) */\n speed?: number;\n}\n\n/**\n * Tile grid of a raster's URL. 'mercator': Web Mercator (XYZ, WMTS PM), the engine's own. 'equirectangular':\n * longitudes and latitudes (Plate Carrée, EPSG:4326-like), two 256 px tiles side by side at level 0, rows from the\n * north (NASA's Trek WMTS, WorldCRS84Quad). A `TileGrid`: the tile matrices of a WMTS in any CRS (Lambert-93…), or a\n * WMS asked for each tile's box in its CRS. The last two are reprojected into Web Mercator tiles by the map's workers\n * (in the page with `workers: false`).\n */\nexport type RasterGrid = 'mercator' | 'equirectangular' | TileGrid;\n\n/** What `RasterLayer.setStyle` changes */\nexport interface RasterStyle {\n opacity: number;\n /** 0 = greyscale, 1 = original colors */\n saturation: number;\n}\n\nexport interface RasterOptions {\n /** Tile URL with {z}, {x} and {y} (256 px tiles); unused with a `loader` */\n url: string;\n /** Tile grid of `url` (default 'mercator'); with 'equirectangular', `minZoom` and `maxZoom` are levels of that\n * grid; with a `TileGrid`, they are map zooms, by default those its matrices span */\n grid?: RasterGrid;\n minZoom?: number;\n maxZoom?: number;\n opacity?: number;\n /** 0 = greyscale, 1 = original colors */\n saturation?: number;\n /** Side of the tiles' textures, pixels (default 256): more for sharper tiles drawn by a `loader` */\n size?: number;\n /** Draws each tile instead of fetching `url`: an image of `size` × `size`, null for nothing there; a rejection is\n * retried like a network error */\n loader?: (z: number, x: number, y: number, signal: AbortSignal) => Promise<ImageBitmap | null>;\n /** Credits of the tiles, HTML: shown by the attribution control while the layer is on the map */\n attribution?: string;\n}\n\nexport interface NetworkStyle {\n /** Line width, CSS pixels, or zoom stops `[[zoom, width], …]` (default 2) */\n width: Size;\n /** Values above are drawn as unreached (default 1800) */\n max: number;\n /** Darker line every `contour` value units, 0 for none (default 0) */\n contour: number;\n opacity: number;\n /** Width of the halo drawn under the lines, CSS pixels or zoom stops, 0 for none (default 0): wide and faint, the\n * reached streets add up into a heat map that fills the blocks */\n halo: Size;\n /** Opacity of the halo at the middle of a line, fading quadratically to its sides (default 0.11) */\n haloOpacity: number;\n /** Colors from 0 to `max`: `[[fraction of max, color], …]` (default green to red) */\n ramp: Ramp | undefined;\n /** Color of the parts beyond `max` or unreached (default `rgba(140, 140, 140, 0.25)`) */\n unreachedColor: string;\n /** Share of `max` over which the colors fade out before it, 0 to 1 (default 0) */\n fade: number;\n}\n\nexport interface NetworkOptions extends Partial<NetworkStyle> {\n /** Node coordinates in degrees: lon0, lat0, lon1, lat1… */\n nodes: Float64Array;\n /** Edges as node index pairs: a0, b0, a1, b1… */\n edges: Uint32Array;\n /** Line of each edge, from A to B: the points of edge e are `points[start[e] .. start[e + 1]]` (lon, lat pairs,\n * counted in points); with fewer than two points an edge is straight. Default: all straight. */\n lines?: { start: Uint32Array; points: Float64Array };\n /** Per edge, the cost of travelling it from A to B then from B to A, in value units (Infinity: closed that way;\n * closed both ways: not drawn). A point along an edge then takes the quickest way there, min(value(A) + cost from\n * A, value(B) + cost from B), as a travel time does. Without costs, values are interpolated along the edges. */\n costs?: Float32Array;\n /** Width factor of each edge (default 1): rail lines wider than streets */\n edgeWidths?: Float32Array;\n}\n\nexport interface Tiles3dStyle {\n /** Screen-space error (CSS pixels) above which a tile is refined: 16 by default, lower is finer and heavier */\n maxScreenSpaceError: number;\n opacity: number;\n /** Size of the points of point cloud tiles (`.pnts`, glTF points), CSS pixels: 2 by default */\n pointSize?: number;\n /** A CSS color multiplying the textures of the meshes, the color of the untextured ones (buildings without\n * textures are light grey without it); none by default */\n color?: string;\n}\n\nexport interface Tiles3dOptions extends Partial<Tiles3dStyle> {\n /** URL of a `tileset.json` (3D Tiles 1.0 b3dm and pnts, 1.1 glb meshes and points, external tilesets) */\n url: string;\n /** Its heights are altitudes above the geoid (NGF-IGN69), as the IGN's Bâtiments 3D, rather than above the\n * ellipsoid (3D Tiles as specified): each tile raised by the RAF20 geoid, onto the IGN relief (default false) */\n geoid?: boolean;\n}\n\nexport interface MapPointerEvent {\n point: Point;\n /** Undefined above the horizon */\n lonLat: LonLat | undefined;\n}\n\n/** What 'hoverfeature' found under the pointer */\nexport interface MapHoverFeatureEvent extends MapPointerEvent {\n /** The feature under the pointer (see `GeoMap.pickFeature`), undefined if none */\n hit: FeatureHit | undefined;\n}\n\n/** A picked feature: its layer handle, its index there and, for line, circle, fill, extrusion, point cloud and 3D\n * Tiles layers, the feature itself (a building of 3D Tiles with its properties) */\nexport interface FeatureHit {\n layer: Layer;\n index: number;\n feature: Feature | undefined;\n}\n\nexport interface MapEvents {\n /** The camera started moving (a gesture, an animation or `setCamera`) */\n movestart: Camera;\n /** The camera moved */\n move: Camera;\n /** The camera stopped: no gesture held, no animation running */\n moveend: Camera;\n /** The map changed size (CSS pixels) */\n resize: { width: number; height: number };\n /** The pointer moved over the map (at most once per frame, not while dragging) */\n hover: MapPointerEvent;\n /** What is under the pointer, picked without stalling the GPU: a frame or two after 'hover', only while listened to\n * (radius and layers in `GeoMap.hoverPicking`) */\n hoverfeature: MapHoverFeatureEvent;\n /** Click without drag */\n click: MapPointerEvent;\n /** A frame was drawn; duration of the engine call in milliseconds */\n render: { ms: number };\n /** Everything in view is loaded and drawn, nothing moves: the end of a load, once after each change (as MapLibre's\n * `idle`). Tiles requested by the first frame count, so it never fires before they arrive. */\n idle: Record<string, never>;\n /** The pointer left the canvas (a mouse going out of the map, or onto a control or marker) */\n leave: Record<string, never>;\n}\n\n/** What a layer handle needs from its map */\nexport interface LayerHost {\n readonly engine: Engine;\n requestRender(): void;\n /** Forgets a removed layer */\n detach(layer: object): void;\n /** Moves a layer under `before`, or on top */\n moveLayer(layer: object, before: object | undefined): void;\n /** A layer created again in the engine (new id): put at the place of its old id, which is removed */\n replaceLayer(layer: object, old: number): void;\n /** Resolves once the map is idle (everything in view loaded and drawn) */\n whenIdle(): Promise<void>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,0CAA0C","sourcesContent":["/** Public types of the `isard` package */\n\nimport type { TileGrid } from './basemap/grid.ts';\nimport type { DecoderUrls } from './engine/decoders.ts';\nimport type { Feature, Ramp, Size } from './layers/features.ts';\nimport type { Layer } from './layers/layers.ts';\nimport type { AttributionOptions } from './ui/controls.ts';\nimport type { Camera, Engine } from './wasm/isard.js';\n\nexport type LonLat = [lon: number, lat: number];\nexport type Point = [x: number, y: number];\n\n/**\n * The named basemaps. OpenFreeMap's vector styles, OpenStreetMap data worldwide, their labels above the other layers:\n * `osm-positron` (light grey, quiet: data over it reads first), `osm-liberty` and `osm-bright` (in colour). The\n * Géoplateforme's (IGN, France): rasters (`ign-plan`, `ign-plan-grey`, `ign-ortho`, the aerial photographs) or vector\n * tiles with their labels (`ign-plan-vector`, `ign-plan-grey-vector`, the PLAN.IGN styles).\n */\nexport type BasemapName =\n | 'osm-positron'\n | 'osm-liberty'\n | 'osm-bright'\n | 'ign-plan'\n | 'ign-plan-grey'\n | 'ign-ortho'\n | 'ign-plan-vector'\n | 'ign-plan-grey-vector'\n | 'none';\n\n/** A basemap by name (see `BasemapName`) */\nexport type Basemap = BasemapName;\n\n/**\n * The Earth's named terrain models. `'terrain-tiles'`: worldwide, the Terrain Tiles of AWS's open data registry\n * (SRTM, EU-DEM, GMTED… merged by Mapzen, 30 m in most places), the sea floor flattened at sea level. `'ign'`: France,\n * the IGN's RGE ALTI from the Géoplateforme (1 to 5 m), raised by the RAF20 geoid to heights above the ellipsoid.\n */\nexport type TerrainModel = 'terrain-tiles' | 'ign';\n\n/** How tiles encode their altitudes: `'float32'`, raw little-endian floats (`image/x-bil;bits=32`, an ArcGIS raw\n * grid); `'terrarium'`, the colors of a PNG, `R × 256 + G + B / 256 - 32768`; `'mapbox'`, those of Terrain-RGB,\n * `(R × 65536 + G × 256 + B) / 10 - 10000` */\nexport type TerrainEncoding = 'float32' | 'terrarium' | 'mapbox';\n\n/**\n * How tiles load and show. 'immediate' (default): everything visible loads, tiles show as soon as they arrive.\n * 'smooth': during flights the levels flown through are skipped, off-center tiles wait while the camera moves, tiles\n * fade in; fewer downloads, for slow networks or GPUs.\n */\nexport type LoadingMode = 'immediate' | 'smooth';\n\n/** 'globe': a sphere at low zoom, blending into Web Mercator between zooms 5 and 7, up to three levels later under a\n * tilted camera (it sees much farther than its center: the horizon stays curved) */\nexport type Projection = 'globe' | 'mercator';\n\n/** A body to draw the map on, other than the named ones (`CelestialBody`) */\nexport interface BodyOptions {\n /** Equatorial radius, metres */\n radius: number;\n /** Flattening of its ellipsoid, 0 for a sphere (default 0) */\n flattening?: number;\n /** An atmosphere: its halo around the globe, true for the Earth's light blue, or a CSS color (its alpha the\n * halo's strength) (default false) */\n atmosphere?: boolean | string;\n /** Color of the globe where no tile covers it (past the Web Mercator latitudes, 85°), a CSS color (default\n * `#808080`) */\n color?: string;\n /** Lowest and highest altitudes of its ground, metres around the ellipsoid: what its relief may raise into view\n * (default ±1 % of the radius) */\n relief?: [lowest: number, highest: number];\n}\n\n/**\n * The body the map is drawn on: 'earth' (WGS 84, the default), 'moon' (a sphere of 1 737 400 m, no atmosphere),\n * 'mars' (a sphere of 3 396 190 m, its equatorial radius, a thin dusty halo; planetocentric latitudes) or another\n * one. Zoom levels keep their meaning on screen (the Web Mercator tile pyramid), their metres follow the body:\n * altitudes, relief, buildings, 3D Tiles. Off the Earth, the map has none of the Earth's defaults: no basemap, no\n * credits, and space for its background; the Moon and Mars have NASA's relief for `terrain: true`.\n */\nexport type CelestialBody = 'earth' | 'moon' | 'mars' | BodyOptions;\n\nexport interface GeoMapOptions extends Partial<Camera> {\n /** The body the map is drawn on (default 'earth'); set at creation */\n body?: CelestialBody;\n /** Default 'globe' */\n projection?: Projection;\n /** Default 'immediate' */\n loading?: LoadingMode;\n /** The basemap (default 'osm-positron'; 'none' off the Earth) */\n basemap?: Basemap;\n /** Opacity of the IGN hillshade over the basemap (France, Géoplateforme), 0 for none (default 0) */\n hillshade?: number;\n /** Color behind the map (sky of tilted flat views), a CSS color (default `#f2f2f0`; black off the Earth) */\n background?: string;\n /** Space behind the globe: stars and atmosphere halo, fading out as the globe turns flat (default true) */\n sky?: boolean;\n /** Relief under the basemap: true for the body's terrain model (on the Earth the worldwide Terrain Tiles; NASA's on\n * the Moon and Mars: LOLA, MOLA), one of the Earth's models by name (`'ign'`: France, RGE ALTI), or its options\n * (default false; on another body, its `url` is required). Network layers are draped on it */\n terrain?: boolean | TerrainModel | TerrainOptions;\n minZoom?: number;\n maxZoom?: number;\n /** Highest pitch, degrees, up to 85 (default 70) */\n maxPitch?: number;\n /** Sky over the plane, seen when the camera is tilted towards the horizon, and the fog the ground fades into\n * (MapLibre's `setSky`); default none: the background color */\n atmosphere?: AtmosphereOptions;\n /** Mouse, touch and keyboard controls (default true) */\n interactive?: boolean;\n /** Keyboard controls once the map has the focus (it is reached with Tab): arrows pan, Shift + arrows rotate and\n * tilt, + and - zoom (Shift: two levels), 0 faces north and levels the view (default true; none when not\n * `interactive`) */\n keyboard?: boolean;\n /** Accessible name of the map, read by screen readers (default 'Map') */\n ariaLabel?: string;\n /** A preset of map options (`IGN_PRESETS`: `'ign'`, `'ign-3d'`, `'ign-ortho-3d'`), the other options over it */\n preset?: 'ign' | 'ign-3d' | 'ign-ortho-3d';\n /** The folder isard's files are served from (its engines, `isard_bg.wasm`, `isard_core_bg.wasm`,\n * `isard_points_bg.wasm`, and its workers, `decoder.worker.js`, `basemap.worker.js`): one option for a bundler that\n * moves them, the `…Url` options below for each one. `isard/vite` sets it for the whole page; default next to the\n * module */\n assetsUrl?: string | URL;\n /** Where to load the engine with 3D Tiles from (`isard_bg.wasm`), when a bundler does not resolve the default URL.\n * Given without `coreWasmUrl`, maps load this engine from the start */\n wasmUrl?: string | URL;\n /** Where to load the engine without 3D Tiles from (`isard_core_bg.wasm`, a third smaller), when a bundler does not\n * resolve the default URL. Maps load it first, and the engine with 3D Tiles (`wasmUrl`) for their first 3D Tiles\n * layer only */\n coreWasmUrl?: string | URL;\n /** Where the decoding workers load the point cloud module from (`isard_points_bg.wasm`, the LAZ decoder of COPC),\n * when a bundler does not resolve the default URL. Loaded with the first point cloud only */\n pointsWasmUrl?: string | URL;\n /** Load the engine with 3D Tiles from the start (default false: it is loaded when the first 3D Tiles layer or glTF\n * model is added, the map then moving its camera and layers onto it, a stall of about a frame or two). For a map that shows 3D Tiles\n * at once: one engine downloaded instead of two. `'preload'`: the map starts on the engine without 3D Tiles and\n * downloads and compiles the other once idle, without running it: its first 3D Tiles layer does not wait for the\n * download (for a map that will show 3D Tiles later, on demand) */\n tiles3d?: boolean | 'preload';\n /** Where to load the vector basemap worker from, when a bundler does not resolve the default URL */\n basemapWorkerUrl?: string | URL;\n /** Texture size of the vector basemap's tiles, pixels (default 512: lines and edges sharp at every zoom on a screen\n * of pixel ratio 1). 256: a quarter of the drawing in the workers, of the uploads and of the GPU memory, for lines\n * and edges a little softer between two zoom levels (the tiles are shown 181 to 362 CSS pixels wide) */\n basemapTileSize?: number;\n /** Glyphs of the symbol layers: a URL with `{fontstack}` and `{range}` (MapLibre's glyph format; default\n * OpenFreeMap's fonts, Noto Sans). A vector basemap's labels take the glyphs of its style */\n glyphs?: string;\n /** Workers decoding 3D Tiles off the main thread: a count, or false to decode on the main thread (default: cores - 1,\n * 1 to 4). False (or 0) also decodes the PNG relief and reprojects the equirectangular rasters on the main thread,\n * else done by the vector basemap's workers */\n workers?: number | false;\n /** Where to load the decoding worker from, when a bundler does not resolve the default URL */\n workerUrl?: string | URL;\n /** Folders of the Draco and Basis Universal decoders, loaded by the workers on first use (default: the official\n * builds on gstatic.com and jsDelivr; self-host them for offline or locked-down networks). They run through\n * `new Function`: a Content Security Policy needs `'unsafe-eval'` (see `DecoderUrls`) */\n decoders?: Partial<DecoderUrls>;\n /** Credits at the bottom right: false for none, or its options (default true: the credits of the basemap,\n * hillshade and relief in use, compact on maps narrower than 640 px) */\n attributionControl?: boolean | AttributionOptions;\n}\n\nexport interface TerrainOptions {\n /** One of the Earth's named models (default `'terrain-tiles'` on the Earth); unused with a `url` */\n model?: TerrainModel;\n /** Altitudes of 256 × 256 tiles in `encoding`: a WMS GetMap URL with {bbox} (EPSG:3857 on the Earth, the body's\n * Mercator metres elsewhere: the sphere of its radius), a tile URL with {z}, {x} and {y}, or an ArcGIS image service\n * (a URL ending in `/ImageServer`), asked for raw altitudes in the body's Mercator (default: the `model`'s; on the\n * Moon and Mars, NASA's Trek LOLA and MOLA models) */\n url?: string;\n /** How the tiles of `url` encode their altitudes (default `'float32'`); `'terrarium'` and `'mapbox'` take a URL with\n * {z}, {x} and {y} */\n encoding?: TerrainEncoding;\n /** Vertical exaggeration, 1 for the true relief (default 1) */\n exaggeration?: number;\n /** Finest level of the relief, up to 15 (default 15; 14 for the Terrain Tiles, 8 for the Moon's and Mars's models). It\n * starts at level 6 on the Earth, coarser on bodies of a larger relief for their size (3 on the Moon and Mars) */\n maxZoom?: number;\n /** Altitudes over mainland France raised by the height of the RAF20 geoid (the French one, 0 away from France), to\n * heights above the ellipsoid (those of 3D Tiles); false keeps the altitudes as served (NGF-IGN69 for the IGN's)\n * (default true for the `'ign'` model, false otherwise) */\n geoid?: boolean;\n}\n\n/** Sky, horizon and fog over the plane, with the names and meanings of MapLibre's `setSky` */\nexport interface AtmosphereOptions {\n /** A CSS color (default `#9cc7ec`) */\n skyColor?: string;\n /** (default `#e8f1f8`) */\n horizonColor?: string;\n /** (default `#f2f5f8`) */\n fogColor?: string;\n /** Blend from the horizon to the sky color, share of the field of view above the horizon, 0-1 (default 0.6) */\n skyHorizonBlend?: number;\n /** Blend from the horizon to the fog color below the horizon, 0-1 (default 0.7) */\n horizonFogBlend?: number;\n /** Share of the distance to the far plane over which the ground fades into the fog, 0-1 (default 0.4) */\n fogGroundBlend?: number;\n}\n\n/** What can be seen from a point (`GeoMap.setViewshed`); with several observers, the colors, the opacity and the\n * cone's color are the first one's */\nexport interface ViewshedOptions {\n /** The observer */\n position: LonLat;\n /** Metres above the ground (default 1.7, eye level) */\n height?: number;\n /** Metres around the observer that are tinted (default 1000) */\n range?: number;\n /** A CSS color for what is seen (default `#2f9e44`) */\n visibleColor?: string;\n /** A CSS color for what is hidden (default `#e03131`) */\n hiddenColor?: string;\n /** How strongly the colors tint the scene, multiplied into it so that its textures and shading stay, 0-1 (default\n * 0.7) */\n opacity?: number;\n /** A CSS color for the cone drawn in 3D (one way only): its fan through the axis, at the eye's height and tilted\n * with it, from the eye to the range; solid where nothing hides it, faint behind the scene; none by default */\n coneColor?: string;\n /** To look one way only (a camera, a lookout), degrees clockwise from north; all around without it */\n direction?: number;\n /** Degrees above the horizon the cone looks, negative below (default 0) */\n tilt?: number;\n /** Angle of view across, degrees (default 60) */\n fov?: number;\n /** Angle of view up and down, degrees (default 40) */\n verticalFov?: number;\n}\n\n/** An eye at street level (`GeoMap.setFirstPerson`) */\nexport interface FirstPersonView {\n /** Where it stands */\n lonLat: LonLat;\n /** Metres above the ground (default 1.7) */\n height?: number;\n /** Degrees clockwise from north it looks to */\n bearing: number;\n /** Degrees from straight down: 90 level (the default), 180 straight up */\n pitch?: number;\n /** Vertical field of view, degrees (default 75) */\n fov?: number;\n}\n\n/** Layers shown on one side of a vertical line only (`GeoMap.setSwipe`) */\nexport interface SwipeOptions {\n /** CSS pixels from the left of the map */\n position: number;\n layers: readonly Layer[];\n /** The side they show on (default 'left') */\n side?: 'left' | 'right';\n}\n\n/** Animation of a camera move */\nexport interface AnimationOptions {\n /** Milliseconds */\n duration?: number;\n /** Progress over time, both 0 to 1 */\n easing?: (t: number) => number;\n}\n\nexport interface FlyToOptions extends AnimationOptions {\n /** How far the flight zooms out on its way, as MapLibre's `curve` (default 1.42) */\n curve?: number;\n /** Average speed in screens per second when `duration` is not given (default 1.2) */\n speed?: number;\n}\n\n/**\n * Tile grid of a raster's URL. 'mercator': Web Mercator (XYZ, WMTS PM), the engine's own. 'equirectangular':\n * longitudes and latitudes (Plate Carrée, EPSG:4326-like), two 256 px tiles side by side at level 0, rows from the\n * north (NASA's Trek WMTS, WorldCRS84Quad). A `TileGrid`: the tile matrices of a WMTS in any CRS (Lambert-93…), or a\n * WMS asked for each tile's box in its CRS. The last two are reprojected into Web Mercator tiles by the map's workers\n * (in the page with `workers: false`).\n */\nexport type RasterGrid = 'mercator' | 'equirectangular' | TileGrid;\n\n/** What `RasterLayer.setStyle` changes */\nexport interface RasterStyle {\n opacity: number;\n /** 0 = greyscale, 1 = original colors */\n saturation: number;\n}\n\nexport interface RasterOptions {\n /** Tile URL with {z}, {x} and {y} (256 px tiles); unused with a `loader` */\n url: string;\n /** Tile grid of `url` (default 'mercator'); with 'equirectangular', `minZoom` and `maxZoom` are levels of that\n * grid; with a `TileGrid`, they are map zooms, by default those its matrices span */\n grid?: RasterGrid;\n minZoom?: number;\n maxZoom?: number;\n opacity?: number;\n /** 0 = greyscale, 1 = original colors */\n saturation?: number;\n /** Side of the tiles' textures, pixels (default 256): more for sharper tiles drawn by a `loader` */\n size?: number;\n /** Draws each tile instead of fetching `url`: an image of `size` × `size`, null for nothing there; a rejection is\n * retried like a network error */\n loader?: (z: number, x: number, y: number, signal: AbortSignal) => Promise<ImageBitmap | null>;\n /** Credits of the tiles, HTML: shown by the attribution control while the layer is on the map */\n attribution?: string;\n}\n\nexport interface NetworkStyle {\n /** Line width, CSS pixels, or zoom stops `[[zoom, width], …]` (default 2) */\n width: Size;\n /** Values above are drawn as unreached (default 1800) */\n max: number;\n /** Darker line every `contour` value units, 0 for none (default 0) */\n contour: number;\n opacity: number;\n /** Width of the halo drawn under the lines, CSS pixels or zoom stops, 0 for none (default 0): wide and faint, the\n * reached streets add up into a heat map that fills the blocks */\n halo: Size;\n /** Opacity of the halo at the middle of a line, fading quadratically to its sides (default 0.11) */\n haloOpacity: number;\n /** Colors from 0 to `max`: `[[fraction of max, color], …]` (default green to red) */\n ramp: Ramp | undefined;\n /** Color of the parts beyond `max` or unreached (default `rgba(140, 140, 140, 0.25)`) */\n unreachedColor: string;\n /** Share of `max` over which the colors fade out before it, 0 to 1 (default 0) */\n fade: number;\n}\n\nexport interface NetworkOptions extends Partial<NetworkStyle> {\n /** Node coordinates in degrees: lon0, lat0, lon1, lat1… */\n nodes: Float64Array;\n /** Edges as node index pairs: a0, b0, a1, b1… */\n edges: Uint32Array;\n /** Line of each edge, from A to B: the points of edge e are `points[start[e] .. start[e + 1]]` (lon, lat pairs,\n * counted in points); with fewer than two points an edge is straight. Default: all straight. */\n lines?: { start: Uint32Array; points: Float64Array };\n /** Per edge, the cost of travelling it from A to B then from B to A, in value units (Infinity: closed that way;\n * closed both ways: not drawn). A point along an edge then takes the quickest way there, min(value(A) + cost from\n * A, value(B) + cost from B), as a travel time does. Without costs, values are interpolated along the edges. */\n costs?: Float32Array;\n /** Width factor of each edge (default 1): rail lines wider than streets */\n edgeWidths?: Float32Array;\n}\n\nexport interface Tiles3dStyle {\n /** Screen-space error (CSS pixels) above which a tile is refined: 16 by default, lower is finer and heavier */\n maxScreenSpaceError: number;\n opacity: number;\n /** Size of the points of point cloud tiles (`.pnts`, glTF points), CSS pixels: 2 by default */\n pointSize?: number;\n /** A CSS color multiplying the textures of the meshes, the color of the untextured ones (buildings without\n * textures are light grey without it); none by default */\n color?: string;\n}\n\nexport interface Tiles3dOptions extends Partial<Tiles3dStyle> {\n /** URL of a `tileset.json` (3D Tiles 1.0 b3dm and pnts, 1.1 glb meshes and points, external tilesets) */\n url: string;\n /** Its heights are altitudes above the geoid (NGF-IGN69), as the IGN's Bâtiments 3D, rather than above the\n * ellipsoid (3D Tiles as specified): each tile raised by the RAF20 geoid, onto the IGN relief (default false) */\n geoid?: boolean;\n}\n\nexport interface MapPointerEvent {\n point: Point;\n /** Undefined above the horizon */\n lonLat: LonLat | undefined;\n}\n\n/** What 'hoverfeature' found under the pointer */\nexport interface MapHoverFeatureEvent extends MapPointerEvent {\n /** The feature under the pointer (see `GeoMap.pickFeature`), undefined if none */\n hit: FeatureHit | undefined;\n}\n\n/** A picked feature: its layer handle, its index there and, for line, circle, fill, extrusion, point cloud and 3D\n * Tiles layers, the feature itself (a building of 3D Tiles with its properties) */\nexport interface FeatureHit {\n layer: Layer;\n index: number;\n feature: Feature | undefined;\n}\n\nexport interface MapEvents {\n /** The camera started moving (a gesture, an animation or `setCamera`) */\n movestart: Camera;\n /** The camera moved */\n move: Camera;\n /** The camera stopped: no gesture held, no animation running */\n moveend: Camera;\n /** The map changed size (CSS pixels) */\n resize: { width: number; height: number };\n /** The pointer moved over the map (at most once per frame, not while dragging) */\n hover: MapPointerEvent;\n /** What is under the pointer, picked without stalling the GPU: a frame or two after 'hover', only while listened to\n * (radius and layers in `GeoMap.hoverPicking`) */\n hoverfeature: MapHoverFeatureEvent;\n /** Click without drag */\n click: MapPointerEvent;\n /** A frame was drawn; duration of the engine call in milliseconds */\n render: { ms: number };\n /** Everything in view is loaded and drawn, nothing moves: the end of a load, once after each change (as MapLibre's\n * `idle`). Tiles requested by the first frame count, so it never fires before they arrive. */\n idle: Record<string, never>;\n /** The pointer left the canvas (a mouse going out of the map, or onto a control or marker) */\n leave: Record<string, never>;\n}\n\n/** What a layer handle needs from its map */\nexport interface LayerHost {\n readonly engine: Engine;\n requestRender(): void;\n /** Forgets a removed layer */\n detach(layer: Layer): void;\n /** Moves a layer under `before`, or on top */\n moveLayer(layer: Layer, before: Layer | undefined): void;\n /** A layer created again in the engine (new id): put at the place of its old id, which is removed */\n replaceLayer(layer: Layer, old: number): void;\n /** Resolves once the map is idle (everything in view loaded and drawn) */\n whenIdle(): Promise<void>;\n}\n"]}
|
package/dist/ui/controls.js
CHANGED
|
@@ -5,7 +5,7 @@ const MINUS = svg('<path d="M9.5 13.5h10a1 1 0 0 1 0 2h-10a1 1 0 0 1 0-2z"/>');
|
|
|
5
5
|
const COMPASS = svg('<path d="M10.5 14 14.5 6.5 18.5 14z" fill="#e3342f"/><path d="M10.5 15 14.5 22.5 18.5 15z" fill="currentColor" opacity="0.5"/>');
|
|
6
6
|
const INFO = '<svg width="20" height="20" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" ' +
|
|
7
7
|
'd="M10 3a7 7 0 1 0 0 14 7 7 0 0 0 0-14zm-1 5.5h2V14H9zM10 5.5a1.1 1.1 0 1 1 0 2.2 1.1 1.1 0 0 1 0-2.2z"/></svg>';
|
|
8
|
-
|
|
8
|
+
const button = (className, label, icon, onClick) => {
|
|
9
9
|
const element = document.createElement('button');
|
|
10
10
|
element.type = 'button';
|
|
11
11
|
element.className = className;
|
|
@@ -14,7 +14,7 @@ function button(className, label, icon, onClick) {
|
|
|
14
14
|
element.innerHTML = icon;
|
|
15
15
|
element.addEventListener('click', onClick);
|
|
16
16
|
return element;
|
|
17
|
-
}
|
|
17
|
+
};
|
|
18
18
|
/** Zoom buttons and compass */
|
|
19
19
|
export class NavigationControl {
|
|
20
20
|
options;
|
|
@@ -33,6 +33,8 @@ export class NavigationControl {
|
|
|
33
33
|
const compass = button('isard-ctrl-compass', 'Reset bearing to north', COMPASS, () => map.easeTo({ bearing: 0, pitch: 0 }, 300));
|
|
34
34
|
const needle = compass.firstElementChild;
|
|
35
35
|
const turn = () => {
|
|
36
|
+
if (!(needle instanceof SVGElement))
|
|
37
|
+
return;
|
|
36
38
|
const { bearing, pitch } = map.getCamera();
|
|
37
39
|
// Seen from above when tilted: the needle lies back with the ground, squashed by cos(pitch)
|
|
38
40
|
needle.style.transform = this.options.visualizePitch
|
|
@@ -67,10 +69,10 @@ export class AttributionControl {
|
|
|
67
69
|
const custom = this.options.customAttribution ?? [];
|
|
68
70
|
const render = () => {
|
|
69
71
|
inner.innerHTML = [...map.attributions(), ...(typeof custom === 'string' ? [custom] : custom)].join(' | ');
|
|
70
|
-
|
|
72
|
+
inner.querySelectorAll('a').forEach((link) => {
|
|
71
73
|
link.target = '_blank';
|
|
72
74
|
link.rel = 'noopener noreferrer';
|
|
73
|
-
}
|
|
75
|
+
});
|
|
74
76
|
};
|
|
75
77
|
render();
|
|
76
78
|
this.stopListening = map.onAttributionChange(render);
|
package/dist/ui/controls.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controls.js","sourceRoot":"","sources":["../../src/ui/controls.ts"],"names":[],"mappings":"AAeA,MAAM,GAAG,GAAG,CAAC,IAAY,EAAE,EAAE,CAC3B,0FAA0F,IAAI,QAAQ,CAAC;AACzG,MAAM,IAAI,GAAG,GAAG,CACd,kHAAkH,CACnH,CAAC;AACF,MAAM,KAAK,GAAG,GAAG,CAAC,2DAA2D,CAAC,CAAC;AAC/E,4DAA4D;AAC5D,MAAM,OAAO,GAAG,GAAG,CACjB,gIAAgI,CACjI,CAAC;AACF,MAAM,I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n * Controls: elements in a corner of the map. A control is anything with `onAdd` and `onRemove`, as in MapLibre, so\n * applications write their own; the navigation buttons and the attribution are built in.\n */\nimport type { GeoMap } from '../map.ts';\n\nexport type ControlPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';\n\nexport interface Control {\n /** Builds the control's element; the map puts it in its corner */\n onAdd(map: GeoMap): HTMLElement;\n /** Cleans up (listeners); the map removes the element */\n onRemove(map: GeoMap): void;\n}\n\nconst svg = (body: string) =>\n `<svg width=\"29\" height=\"29\" viewBox=\"0 0 29 29\" fill=\"currentColor\" aria-hidden=\"true\">${body}</svg>`;\nconst PLUS = svg(\n '<path d=\"M14.5 8.5a1 1 0 0 1 1 1v4h4a1 1 0 0 1 0 2h-4v4a1 1 0 0 1-2 0v-4h-4a1 1 0 0 1 0-2h4v-4a1 1 0 0 1 1-1z\"/>',\n);\nconst MINUS = svg('<path d=\"M9.5 13.5h10a1 1 0 0 1 0 2h-10a1 1 0 0 1 0-2z\"/>');\n/** Needle: red half to the north, grey half to the south */\nconst COMPASS = svg(\n '<path d=\"M10.5 14 14.5 6.5 18.5 14z\" fill=\"#e3342f\"/><path d=\"M10.5 15 14.5 22.5 18.5 15z\" fill=\"currentColor\" opacity=\"0.5\"/>',\n);\nconst INFO =\n '<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"currentColor\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" ' +\n 'd=\"M10 3a7 7 0 1 0 0 14 7 7 0 0 0 0-14zm-1 5.5h2V14H9zM10 5.5a1.1 1.1 0 1 1 0 2.2 1.1 1.1 0 0 1 0-2.2z\"/></svg>';\n\nfunction button(className: string, label: string, icon: string, onClick: () => void): HTMLButtonElement {\n const element = document.createElement('button');\n element.type = 'button';\n element.className = className;\n element.title = label;\n element.setAttribute('aria-label', label);\n element.innerHTML = icon;\n element.addEventListener('click', onClick);\n return element;\n}\n\nexport interface NavigationOptions {\n /** Zoom in and out buttons (default true) */\n showZoom?: boolean;\n /** Compass turning with the bearing; a click faces north and levels the view (default true) */\n showCompass?: boolean;\n /** The compass also tilts with the pitch (default false) */\n visualizePitch?: boolean;\n}\n\n/** Zoom buttons and compass */\nexport class NavigationControl implements Control {\n private readonly options: Required<NavigationOptions>;\n private stopListening: (() => void) | undefined;\n\n constructor(options: NavigationOptions = {}) {\n this.options = { showZoom: true, showCompass: true, visualizePitch: false, ...options };\n }\n\n onAdd(map: GeoMap): HTMLElement {\n const group = document.createElement('div');\n group.className = 'isard-ctrl-group';\n const zoomBy = (delta: number) => map.easeTo({ zoom: map.getCamera().zoom + delta }, 300);\n if (this.options.showZoom) {\n group.append(\n button('isard-ctrl-zoom-in', 'Zoom in', PLUS, () => zoomBy(1)),\n button('isard-ctrl-zoom-out', 'Zoom out', MINUS, () => zoomBy(-1)),\n );\n }\n if (this.options.showCompass) {\n const compass = button('isard-ctrl-compass', 'Reset bearing to north', COMPASS, () =>\n map.easeTo({ bearing: 0, pitch: 0 }, 300),\n );\n const needle = compass.firstElementChild as SVGElement;\n const turn = () => {\n const { bearing, pitch } = map.getCamera();\n // Seen from above when tilted: the needle lies back with the ground, squashed by cos(pitch)\n needle.style.transform = this.options.visualizePitch\n ? `scale(${1 / Math.cos((pitch * Math.PI) / 180) ** 0.5}) rotateX(${pitch}deg) rotateZ(${-bearing}deg)`\n : `rotate(${-bearing}deg)`;\n };\n turn();\n this.stopListening = map.on('move', turn);\n group.append(compass);\n }\n return group;\n }\n\n onRemove(): void {\n this.stopListening?.();\n this.stopListening = undefined;\n }\n}\n\nexport interface AttributionOptions {\n /** Folded into a small (i) button that shows the text on click (default: when the map is narrower than 640 px) */\n compact?: boolean;\n /** Attributions shown after those of the map's sources, HTML allowed (links open in a new tab) */\n customAttribution?: string | string[];\n}\n\n/** Credits of the data shown: those of the map's basemap, hillshade and relief (OpenFreeMap and OpenStreetMap, IGN,\n * the Terrain Tiles…, followed as they change), then the page's own */\nexport class AttributionControl implements Control {\n private observer: ResizeObserver | undefined;\n private stopListening: (() => void) | undefined;\n\n constructor(private readonly options: AttributionOptions = {}) {}\n\n onAdd(map: GeoMap): HTMLElement {\n const element = document.createElement('div');\n element.className = 'isard-attrib';\n const inner = document.createElement('div');\n inner.className = 'isard-attrib-inner';\n const custom = this.options.customAttribution ?? [];\n const render = () => {\n inner.innerHTML = [...map.attributions(), ...(typeof custom === 'string' ? [custom] : custom)].join(' | ');\n for (const link of inner.querySelectorAll('a')) {\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n }\n };\n render();\n this.stopListening = map.onAttributionChange(render);\n const toggle = button('isard-attrib-button', 'Toggle attribution', INFO, () =>\n toggle.setAttribute('aria-expanded', String(element.classList.toggle('isard-attrib-open'))),\n );\n toggle.setAttribute('aria-expanded', 'false');\n element.append(inner, toggle);\n const { compact } = this.options;\n if (compact !== undefined) {\n element.classList.toggle('isard-attrib-compact', compact);\n } else {\n // Follows the map's width; a narrowed map folds the text, starting closed\n const fold = () => {\n const narrow = map.getContainer().clientWidth < 640;\n if (narrow !== element.classList.contains('isard-attrib-compact')) {\n element.classList.remove('isard-attrib-open');\n toggle.setAttribute('aria-expanded', 'false');\n }\n element.classList.toggle('isard-attrib-compact', narrow);\n };\n fold();\n this.observer = new ResizeObserver(fold);\n this.observer.observe(map.getContainer());\n }\n return element;\n }\n\n onRemove(): void {\n this.observer?.disconnect();\n this.observer = undefined;\n this.stopListening?.();\n this.stopListening = undefined;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"controls.js","sourceRoot":"","sources":["../../src/ui/controls.ts"],"names":[],"mappings":"AAeA,MAAM,GAAG,GAAG,CAAC,IAAY,EAAE,EAAE,CAC3B,0FAA0F,IAAI,QAAQ,CAAC;AACzG,MAAM,IAAI,GAAG,GAAG,CACd,kHAAkH,CACnH,CAAC;AACF,MAAM,KAAK,GAAG,GAAG,CAAC,2DAA2D,CAAC,CAAC;AAC/E,4DAA4D;AAC5D,MAAM,OAAO,GAAG,GAAG,CACjB,gIAAgI,CACjI,CAAC;AAC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SAAS,CAAC;QAC1B,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC;QACvB,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC;IACjC,CAAC;CACF","sourcesContent":["/**\n * Controls: elements in a corner of the map. A control is anything with `onAdd` and `onRemove`, as in MapLibre, so\n * applications write their own; the navigation buttons and the attribution are built in.\n */\nimport type { GeoMap } from '../map.ts';\n\nexport type ControlPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';\n\nexport interface Control {\n /** Builds the control's element; the map puts it in its corner */\n onAdd(map: GeoMap): HTMLElement;\n /** Cleans up (listeners); the map removes the element */\n onRemove(map: GeoMap): void;\n}\n\nconst svg = (body: string) =>\n `<svg width=\"29\" height=\"29\" viewBox=\"0 0 29 29\" fill=\"currentColor\" aria-hidden=\"true\">${body}</svg>`;\nconst PLUS = svg(\n '<path d=\"M14.5 8.5a1 1 0 0 1 1 1v4h4a1 1 0 0 1 0 2h-4v4a1 1 0 0 1-2 0v-4h-4a1 1 0 0 1 0-2h4v-4a1 1 0 0 1 1-1z\"/>',\n);\nconst MINUS = svg('<path d=\"M9.5 13.5h10a1 1 0 0 1 0 2h-10a1 1 0 0 1 0-2z\"/>');\n/** Needle: red half to the north, grey half to the south */\nconst COMPASS = svg(\n '<path d=\"M10.5 14 14.5 6.5 18.5 14z\" fill=\"#e3342f\"/><path d=\"M10.5 15 14.5 22.5 18.5 15z\" fill=\"currentColor\" opacity=\"0.5\"/>',\n);\nconst INFO =\n '<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"currentColor\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" ' +\n 'd=\"M10 3a7 7 0 1 0 0 14 7 7 0 0 0 0-14zm-1 5.5h2V14H9zM10 5.5a1.1 1.1 0 1 1 0 2.2 1.1 1.1 0 0 1 0-2.2z\"/></svg>';\n\nconst button = (className: string, label: string, icon: string, onClick: () => void): HTMLButtonElement => {\n const element = document.createElement('button');\n\n element.type = 'button';\n element.className = className;\n element.title = label;\n element.setAttribute('aria-label', label);\n element.innerHTML = icon;\n element.addEventListener('click', onClick);\n\n return element;\n};\n\nexport interface NavigationOptions {\n /** Zoom in and out buttons (default true) */\n showZoom?: boolean;\n /** Compass turning with the bearing; a click faces north and levels the view (default true) */\n showCompass?: boolean;\n /** The compass also tilts with the pitch (default false) */\n visualizePitch?: boolean;\n}\n\n/** Zoom buttons and compass */\nexport class NavigationControl implements Control {\n private readonly options: Required<NavigationOptions>;\n private stopListening: (() => void) | undefined;\n\n constructor(options: NavigationOptions = {}) {\n this.options = { showZoom: true, showCompass: true, visualizePitch: false, ...options };\n }\n\n onAdd(map: GeoMap): HTMLElement {\n const group = document.createElement('div');\n\n group.className = 'isard-ctrl-group';\n\n const zoomBy = (delta: number) => map.easeTo({ zoom: map.getCamera().zoom + delta }, 300);\n\n if (this.options.showZoom) {\n group.append(\n button('isard-ctrl-zoom-in', 'Zoom in', PLUS, () => zoomBy(1)),\n button('isard-ctrl-zoom-out', 'Zoom out', MINUS, () => zoomBy(-1)),\n );\n }\n if (this.options.showCompass) {\n const compass = button('isard-ctrl-compass', 'Reset bearing to north', COMPASS, () =>\n map.easeTo({ bearing: 0, pitch: 0 }, 300),\n );\n const needle = compass.firstElementChild;\n const turn = () => {\n if (!(needle instanceof SVGElement)) return;\n\n const { bearing, pitch } = map.getCamera();\n\n // Seen from above when tilted: the needle lies back with the ground, squashed by cos(pitch)\n needle.style.transform = this.options.visualizePitch\n ? `scale(${1 / Math.cos((pitch * Math.PI) / 180) ** 0.5}) rotateX(${pitch}deg) rotateZ(${-bearing}deg)`\n : `rotate(${-bearing}deg)`;\n };\n\n turn();\n this.stopListening = map.on('move', turn);\n group.append(compass);\n }\n\n return group;\n }\n\n onRemove(): void {\n this.stopListening?.();\n this.stopListening = undefined;\n }\n}\n\nexport interface AttributionOptions {\n /** Folded into a small (i) button that shows the text on click (default: when the map is narrower than 640 px) */\n compact?: boolean;\n /** Attributions shown after those of the map's sources, HTML allowed (links open in a new tab) */\n customAttribution?: string | string[];\n}\n\n/** Credits of the data shown: those of the map's basemap, hillshade and relief (OpenFreeMap and OpenStreetMap, IGN,\n * the Terrain Tiles…, followed as they change), then the page's own */\nexport class AttributionControl implements Control {\n private observer: ResizeObserver | undefined;\n private stopListening: (() => void) | undefined;\n\n constructor(private readonly options: AttributionOptions = {}) {}\n\n onAdd(map: GeoMap): HTMLElement {\n const element = document.createElement('div');\n\n element.className = 'isard-attrib';\n\n const inner = document.createElement('div');\n\n inner.className = 'isard-attrib-inner';\n\n const custom = this.options.customAttribution ?? [];\n const render = () => {\n inner.innerHTML = [...map.attributions(), ...(typeof custom === 'string' ? [custom] : custom)].join(' | ');\n inner.querySelectorAll('a').forEach((link) => {\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n });\n };\n\n render();\n this.stopListening = map.onAttributionChange(render);\n\n const toggle = button('isard-attrib-button', 'Toggle attribution', INFO, () =>\n toggle.setAttribute('aria-expanded', String(element.classList.toggle('isard-attrib-open'))),\n );\n\n toggle.setAttribute('aria-expanded', 'false');\n element.append(inner, toggle);\n\n const { compact } = this.options;\n\n if (compact !== undefined) {\n element.classList.toggle('isard-attrib-compact', compact);\n } else {\n // Follows the map's width; a narrowed map folds the text, starting closed\n const fold = () => {\n const narrow = map.getContainer().clientWidth < 640;\n\n if (narrow !== element.classList.contains('isard-attrib-compact')) {\n element.classList.remove('isard-attrib-open');\n toggle.setAttribute('aria-expanded', 'false');\n }\n element.classList.toggle('isard-attrib-compact', narrow);\n };\n\n fold();\n this.observer = new ResizeObserver(fold);\n this.observer.observe(map.getContainer());\n }\n\n return element;\n }\n\n onRemove(): void {\n this.observer?.disconnect();\n this.observer = undefined;\n this.stopListening?.();\n this.stopListening = undefined;\n }\n}\n"]}
|
package/dist/ui/interaction.d.ts
CHANGED
|
@@ -19,10 +19,10 @@ export type KeyAction = {
|
|
|
19
19
|
};
|
|
20
20
|
/** The action of a key (`KeyboardEvent.key`), as MapLibre's: arrows pan (with Shift: rotate and tilt), + and - zoom
|
|
21
21
|
* (with Shift: two levels), 0 faces north and levels the view */
|
|
22
|
-
export declare
|
|
22
|
+
export declare const keyAction: (key: string, shift: boolean) => KeyAction | undefined;
|
|
23
23
|
/** The camera after a key's action: a pan moves the center by that many CSS pixels on screen (the ground in view,
|
|
24
24
|
* turned with the bearing, stretched by the tilt) */
|
|
25
|
-
export declare
|
|
25
|
+
export declare const keyCamera: (action: KeyAction, camera: Camera) => Partial<Camera>;
|
|
26
26
|
export declare class Interaction {
|
|
27
27
|
private readonly map;
|
|
28
28
|
private readonly pointers;
|
package/dist/ui/interaction.js
CHANGED
|
@@ -23,7 +23,7 @@ const KEY_PITCH = 10;
|
|
|
23
23
|
const KEY_DURATION = 300;
|
|
24
24
|
/** The action of a key (`KeyboardEvent.key`), as MapLibre's: arrows pan (with Shift: rotate and tilt), + and - zoom
|
|
25
25
|
* (with Shift: two levels), 0 faces north and levels the view */
|
|
26
|
-
export
|
|
26
|
+
export const keyAction = (key, shift) => {
|
|
27
27
|
switch (key) {
|
|
28
28
|
case 'ArrowLeft':
|
|
29
29
|
return shift ? { bearing: -KEY_BEARING } : { pan: [-KEY_PAN, 0] };
|
|
@@ -44,10 +44,10 @@ export function keyAction(key, shift) {
|
|
|
44
44
|
default:
|
|
45
45
|
return undefined;
|
|
46
46
|
}
|
|
47
|
-
}
|
|
47
|
+
};
|
|
48
48
|
/** The camera after a key's action: a pan moves the center by that many CSS pixels on screen (the ground in view,
|
|
49
49
|
* turned with the bearing, stretched by the tilt) */
|
|
50
|
-
export
|
|
50
|
+
export const keyCamera = (action, camera) => {
|
|
51
51
|
if ('zoom' in action)
|
|
52
52
|
return { zoom: camera.zoom + action.zoom };
|
|
53
53
|
if ('bearing' in action)
|
|
@@ -67,13 +67,13 @@ export function keyCamera(action, camera) {
|
|
|
67
67
|
const y = Math.max(0, Math.min(1, mercatorY(lat) + dy));
|
|
68
68
|
const wrapped = ((((x * 360) % 360) + 360) % 360) - 180;
|
|
69
69
|
return { center: [wrapped, latitude(y)] };
|
|
70
|
-
}
|
|
70
|
+
};
|
|
71
71
|
/** An element that takes the keys typed in it */
|
|
72
|
-
|
|
72
|
+
const editable = (target) => {
|
|
73
73
|
if (!(target instanceof HTMLElement))
|
|
74
74
|
return false;
|
|
75
75
|
return target.isContentEditable || ['INPUT', 'TEXTAREA', 'SELECT'].includes(target.tagName);
|
|
76
|
-
}
|
|
76
|
+
};
|
|
77
77
|
export class Interaction {
|
|
78
78
|
map;
|
|
79
79
|
pointers = new Map();
|
|
@@ -135,8 +135,9 @@ export class Interaction {
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
destroy() {
|
|
138
|
-
|
|
138
|
+
this.cleanup.forEach((off) => {
|
|
139
139
|
off();
|
|
140
|
+
});
|
|
140
141
|
}
|
|
141
142
|
/** A gesture holds the map (pointers down): the camera has not stopped moving */
|
|
142
143
|
get active() {
|