@apexara/map 1.1.1 → 1.3.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.
@@ -1 +1 @@
1
- {"version":3,"file":"apexara-map.mjs","sources":["../../../../projects/apexara/map/src/lib/mapbox.service.ts","../../../../projects/apexara/map/src/lib/apex-map/apex-map.component.ts","../../../../projects/apexara/map/src/lib/apex-map/apex-map.component.html","../../../../projects/apexara/map/src/lib/map.utils.ts","../../../../projects/apexara/map/apexara-map.ts"],"sourcesContent":["import { isPlatformBrowser } from '@angular/common';\nimport { DestroyRef, Injectable, PLATFORM_ID, Signal, WritableSignal, inject, signal } from '@angular/core';\n\nimport { Subject } from 'rxjs';\n\nimport MapboxDraw from '@mapbox/mapbox-gl-draw';\nimport mapboxgl, { LayerSpecification } from 'mapbox-gl';\n\nimport { MAP_CONFIG, MapStyles } from '@apexara/map/config';\n\nimport type * as GeoJSON from 'geojson';\nimport type { Position } from 'geojson';\n\nimport { MapImageOptions, MapImageSource, MapInitOptions, SourceConfig } from './map.types';\n\n/**\n * Mapbox Service — wrapper around a `mapboxgl.Map` instance.\n *\n * Terms:\n * - Feature: A GeoJSON geometry (Point/LineString/Polygon/…) drawn on the map.\n * - Properties: Arbitrary key-value pairs on `feature.properties`.\n * - Source: Raw data (GeoJSON, vector tiles, raster tiles) added with `addSource`.\n * - Layer: A visual rendering (circle, fill, heatmap, raster, …) bound to a source.\n * - Cluster: A grouped feature emitted when `cluster: true` is set on a GeoJSON source.\n *\n * Browser-only: `init()` is a no-op on the server. Methods other than `init()` assume\n * the map instance exists and must only be called after `ready()` becomes true.\n */\n\n// Process-lifetime cache of parsed Mapbox style JSON keyed by URL. Subsequent\n// inits with the same URL pass the cached object to the Map constructor\n// instead of re-fetching `api.mapbox.com/styles/v1/...`.\nconst styleCache = new Map<string, mapboxgl.StyleSpecification>();\n\n@Injectable({ providedIn: 'root' })\nexport class MapboxService {\n\n /** Click on empty canvas (no features under the cursor). Event stream. */\n public mapClick = new Subject<mapboxgl.MapMouseEvent>();\n\n /** Click on a feature (wired by consumers via `on('click', layerId, ...)`). Event stream. */\n public featureClick = new Subject<mapboxgl.MapMouseEvent>();\n\n /** Fires when the user completes a polygon in draw mode (double-click or first-vertex click). */\n public polygonCreate = new Subject<GeoJSON.Feature<GeoJSON.Polygon>>();\n\n private readonly _ready = signal<boolean>(false);\n\n /** Reactive state: `true` once the map's `load` event has fired. */\n public readonly ready: Signal<boolean> = this._ready;\n\n /** Reactive state: current center `[lng, lat]`. Updates on `moveend`. `null` before init. */\n public readonly center = signal<[number, number] | null>(null);\n\n /** Reactive state: current zoom level. Updates on `moveend`. `null` before init. */\n public readonly zoom = signal<number | null>(null);\n\n /** Reactive state: current viewport bounds `[[swLng, swLat], [neLng, neLat]]`. Updates on `moveend`. */\n public readonly bounds = signal<[[number, number], [number, number]] | null>(null);\n\n /** Reactive state: `true` while the map is panning/zooming (between `movestart` and `moveend`). */\n public readonly isMoving = signal<boolean>(false);\n\n private map!: mapboxgl.Map;\n // `map` stays non-null-typed so existing call-sites don't need guards;\n // this flag tracks whether the constructor has actually run.\n private mapInitialised = false;\n private draw?: MapboxDraw;\n private readonly config = inject(MAP_CONFIG);\n private readonly platformId = inject(PLATFORM_ID);\n\n private onDrawCreate?: (e: { features: GeoJSON.Feature[] }) => void;\n private savedInteractions?: Record<'dragPan' | 'scrollZoom' | 'boxZoom' | 'doubleClickZoom' | 'touchZoomRotate' | 'keyboard', boolean>;\n\n // mapbox-gl is given this stable element (not the consumer's `<div>`).\n // The service re-parents `hostDiv` between consumer containers on context\n // swaps so the underlying `mapboxgl.Map` survives → one billed load per session.\n private hostDiv: HTMLDivElement | null = null;\n\n private containerStack: HTMLElement[] = [];\n\n private readonly _activeContainer: WritableSignal<HTMLElement | null> = signal(null);\n public readonly activeContainer: Signal<HTMLElement | null> = this._activeContainer;\n\n // Whether this browser can run mapbox; null until asked. Kept, since mapbox's check builds a worker and a canvas.\n private supported: boolean | null = null;\n\n /** Back-compat wrapper around `activate`. SSR-safe. */\n public async init(options: MapInitOptions): Promise<void> {\n if (!isPlatformBrowser(this.platformId)) {\n return;\n }\n this.activate(options.container, options);\n }\n\n /** Whether this browser can run mapbox (WebGL2, workers, canvas reads). Asked once; false on the server. */\n public isSupported(): boolean {\n this.supported ??= isPlatformBrowser(this.platformId) && mapboxgl.supported();\n\n return this.supported;\n }\n\n /**\n * Puts the shared map on `container`. False when it did not start there: on the server, in a browser that cannot run\n * mapbox, or when the first start throws (undone and reported). A running map's errors still throw.\n */\n public activate(container: HTMLElement, options: MapInitOptions): boolean {\n if (!this.isSupported()) {\n return false;\n }\n\n if (!this.mapInitialised) {\n return this.startMap(container, options);\n }\n\n const active = this._activeContainer();\n\n if (active === container) {\n if (options.center) {\n this.map.jumpTo({ center: options.center, zoom: options.zoom ?? this.map.getZoom() });\n }\n requestAnimationFrame(() => this.map.resize());\n\n return true;\n }\n\n this.hostDiv?.remove();\n if (this.hostDiv) {\n this.hostDiv.style.display = '';\n container.appendChild(this.hostDiv);\n }\n\n this.containerStack = this.containerStack.filter((c) => c !== container);\n this.containerStack.push(container);\n this._activeContainer.set(container);\n\n if (options.center) {\n this.map.jumpTo({ center: options.center, zoom: options.zoom ?? this.map.getZoom() });\n }\n requestAnimationFrame(() => this.map.resize());\n\n return true;\n }\n\n public deactivate(container: HTMLElement): void {\n if (!isPlatformBrowser(this.platformId)) {\n return;\n }\n\n const wasActive = this._activeContainer() === container;\n this.containerStack = this.containerStack.filter((c) => c !== container);\n\n if (!wasActive) {\n return;\n }\n\n const next = this.containerStack[this.containerStack.length - 1];\n\n this.hostDiv?.remove();\n\n if (next && this.hostDiv) {\n this.hostDiv.style.display = '';\n next.appendChild(this.hostDiv);\n this._activeContainer.set(next);\n requestAnimationFrame(() => this.map.resize());\n return;\n }\n\n if (this.hostDiv) {\n document.body.appendChild(this.hostDiv);\n this.hostDiv.style.display = 'none';\n }\n this._activeContainer.set(null);\n }\n\n // The first start. It can pass isSupported and still throw (e.g. at the browser's limit of WebGL contexts) after its\n // host div went into the container: the div comes back out, so the container is left as it was.\n private startMap(container: HTMLElement, options: MapInitOptions): boolean {\n try {\n this.createMap(container, options);\n } catch (error) {\n this.hostDiv?.remove();\n this.hostDiv = null;\n console.error('[@apexara/map] The map failed to start.', error);\n\n return false;\n }\n\n this.containerStack.push(container);\n this._activeContainer.set(container);\n\n return true;\n }\n\n private createMap(container: HTMLElement, options: MapInitOptions): void {\n const defaultBounds: mapboxgl.LngLatBoundsLike = [\n [-175, -85],\n [175, 85],\n ];\n\n const styleInput = options.mapStyle || this.config.defaultStyle || MapStyles.Streets;\n const styleUrl = typeof styleInput === 'string' ? styleInput : null;\n const cachedStyle = styleUrl ? styleCache.get(styleUrl) : undefined;\n\n this.hostDiv = document.createElement('div');\n this.hostDiv.style.cssText = 'position:absolute;inset:0;width:100%;height:100%;';\n container.appendChild(this.hostDiv);\n\n this.map = new mapboxgl.Map({\n center: options.center,\n zoom: options.zoom || 10,\n accessToken: this.config.accessToken,\n container: this.hostDiv,\n style: (cachedStyle ?? styleInput) as string,\n fadeDuration: 0,\n pitch: 0,\n bearing: 0,\n dragRotate: false,\n pitchWithRotate: false,\n projection: 'mercator',\n maxBounds: options.maxBounds ?? defaultBounds,\n renderWorldCopies: false,\n // Required for `canvas.toDataURL()` to return pixels — consumers that\n // snapshot the canvas (e.g. freeze-frame overlays) rely on this.\n preserveDrawingBuffer: true,\n });\n this.mapInitialised = true;\n\n if (styleUrl && !cachedStyle) {\n this.map.once('style.load', () => {\n styleCache.set(styleUrl, this.map.getStyle() as mapboxgl.StyleSpecification);\n });\n }\n\n this.center.set(options.center);\n this.zoom.set(options.zoom ?? 10);\n\n this.map.on('movestart', () => this.isMoving.set(true));\n\n this.map.on('moveend', () => {\n const c = this.map.getCenter();\n const b = this.map.getBounds() as mapboxgl.LngLatBounds;\n const sw = b.getSouthWest();\n const ne = b.getNorthEast();\n\n this.center.set([c.lng, c.lat]);\n this.zoom.set(this.map.getZoom());\n this.bounds.set([[sw.lng, sw.lat], [ne.lng, ne.lat]]);\n this.isMoving.set(false);\n });\n\n this.map.once('load', () => {\n if (options.showNavigation !== false) {\n this.map.addControl(\n new mapboxgl.NavigationControl({ showCompass: false, showZoom: true }),\n );\n }\n\n this._ready.set(true);\n });\n }\n\n /** Current map center as a `LngLat`. Prefer the `center` signal for reactive reads. */\n public getCenter(): mapboxgl.LngLat {\n return this.map.getCenter();\n }\n\n /** Current zoom level. Prefer the `zoom` signal for reactive reads. */\n public getZoom(): number {\n return this.map.getZoom();\n }\n\n /** The live `mapboxgl.Map`, for mapbox APIs this service does not wrap. `undefined` until the first `init`/`activate`. */\n public getMap(): mapboxgl.Map | undefined {\n return this.mapInitialised ? this.map : undefined;\n }\n\n /**\n * Resolves once the style is parsed, so sources and layers can be added: after a re-parent `ready()` (a one-time\n * latch) says nothing about that. Resolves at once with no map; pass `destroyRef` to resolve on teardown, not hang.\n */\n public whenStyleReady(destroyRef?: DestroyRef): Promise<void> {\n if (!this.mapInitialised || this.isStyleParsed()) {\n return Promise.resolve();\n }\n\n return new Promise((resolve) => {\n let removeDestroyHook: (() => void) | undefined;\n\n const done = (): void => {\n this.map.off('style.load', done);\n this.map.off('idle', done);\n removeDestroyHook?.();\n resolve();\n };\n\n // `idle` always fires once the map settles, so a `style.load` that already fired cannot hang the wait.\n this.map.once('style.load', done);\n this.map.once('idle', done);\n removeDestroyHook = destroyRef?.onDestroy(done);\n });\n }\n\n /**\n * Return the current viewport as a closed GeoJSON-style polygon ring\n * (`[sw, se, ne, nw, sw]`). Useful for point-in-polygon queries against the\n * visible area.\n */\n public getViewportPolygon(): Position[][] {\n const bounds = this.map.getBounds() as mapboxgl.LngLatBounds;\n\n const sw = bounds.getSouthWest();\n const se = bounds.getSouthEast();\n const ne = bounds.getNorthEast();\n const nw = bounds.getNorthWest();\n\n return [\n [\n [sw.lng, sw.lat],\n [se.lng, se.lat],\n [ne.lng, ne.lat],\n [nw.lng, nw.lat],\n [sw.lng, sw.lat],\n ],\n ];\n }\n\n /**\n * Extract `properties` from the first feature under a click/hover event,\n * cast to `T`. Returns `undefined` when no feature was hit or it has no props.\n */\n public getFeatureProperties<T>(mouseEvent: mapboxgl.MapMouseEvent): T | undefined {\n const feature = mouseEvent.features?.[0];\n\n if (!feature) {\n return undefined;\n }\n\n const properties = feature.properties;\n\n if (!properties) {\n return undefined;\n }\n\n return properties as T;\n }\n\n /**\n * Expand a cluster into its individual leaf features (up to `limit`, paginated\n * via `offset`). Rejects if `sourceId` is missing or not a clustered GeoJSON source.\n */\n public async getClusterProperties(\n sourceId: string,\n clusterId: number,\n limit = 10000,\n offset = 0,\n ): Promise<mapboxgl.GeoJSONFeature[]> {\n return new Promise((resolve, reject) => {\n const src = this.map.getSource(sourceId) as unknown as {\n getClusterLeaves?: (\n clusterId: number,\n limit: number,\n offset: number,\n callback: (err: unknown, features: mapboxgl.GeoJSONFeature[]) => void,\n ) => void;\n };\n\n if (!src || typeof src.getClusterLeaves !== 'function') {\n reject(\n new Error(`Source '${sourceId}' is not a clustered GeoJSON source or is missing.`),\n );\n\n return;\n }\n\n src.getClusterLeaves(clusterId, limit, offset, (err, features) => {\n if (err) {\n reject(err);\n } else {\n resolve(features);\n }\n });\n });\n }\n\n /**\n * Query features rendered at a screen point, optionally restricted to specific layers.\n * Returns `[]` when the map has not been initialised yet.\n */\n public getRenderedFeatures(point: mapboxgl.PointLike, params?: { layers?: string[] }): mapboxgl.GeoJSONFeature[] {\n return this.map ? this.map.queryRenderedFeatures(point, params) : [];\n }\n\n /** Swap the base style. Custom sources/layers you added must be re-applied after `styledata`. */\n public setStyle(styleUrl: string): void {\n const cachedStyle = styleCache.get(styleUrl);\n this.map.setStyle((cachedStyle ?? styleUrl) as string);\n\n if (!cachedStyle) {\n this.map.once('style.load', () => {\n styleCache.set(styleUrl, this.map.getStyle() as mapboxgl.StyleSpecification);\n });\n }\n }\n\n /** Animate the camera to `center` at the given zoom (default 13). */\n public moveCenter(center: [number, number], zoom = 13): void {\n this.map.flyTo({ center, zoom });\n }\n\n /** Fit the viewport to `bounds` with optional pixel padding (default 40). */\n public fitBounds(bounds: mapboxgl.LngLatBoundsLike, padding = 40): void {\n this.map.fitBounds(bounds, { padding, duration: 1000 });\n }\n\n /**\n * Add a GeoJSON source. Pass `clustered: true` and optional `clusterRadius`/`clusterMaxZoom`\n * for point clustering. Set `generateId: true` when you plan to use feature-state.\n */\n public addSource(config: SourceConfig): void {\n const src: mapboxgl.GeoJSONSourceSpecification = {\n type: 'geojson',\n data: config.data,\n };\n\n if (config.clustered !== undefined) {\n src.cluster = config.clustered;\n }\n\n if (config.clusterRadius !== undefined) {\n src.clusterRadius = config.clusterRadius;\n }\n\n if (config.clusterMaxZoom !== undefined) {\n src.clusterMaxZoom = config.clusterMaxZoom;\n }\n\n if (config.generateId !== undefined) {\n src.generateId = config.generateId;\n }\n\n this.map.addSource(config.id, src);\n }\n\n /** Replace the data of an existing GeoJSON source in place. No-op if the source is missing. */\n public updateSource(id: string, data: GeoJSON.FeatureCollection): void {\n const source = this.map.getSource(id);\n\n if (source && 'setData' in source) {\n (source as mapboxgl.GeoJSONSource).setData(data);\n }\n }\n\n /**\n * Add a layer to the style. Pass `beforeId` to insert the new layer beneath\n * an existing one (useful for controlling draw order against style layers).\n */\n public addLayer(layer: LayerSpecification, beforeId?: string): void {\n if (beforeId) {\n this.map.addLayer(layer, beforeId);\n } else {\n this.map.addLayer(layer);\n }\n }\n\n /**\n * Add a raster layer backed by a source with the same id. Starts hidden —\n * toggle with `toggleLayerVisibility(id)` or `setLayoutProperty`.\n */\n public addRasterLayer(id: string, _url: string): void {\n this.map.addLayer({\n id,\n type: 'raster',\n source: id,\n layout: { visibility: 'none' },\n });\n }\n\n /** Add a vector tile source from a TileJSON URL (typically `mapbox://...`). */\n public addVectorSource(id: string, url: string): void {\n this.map.addSource(id, {\n type: 'vector',\n url,\n } as mapboxgl.VectorSourceSpecification);\n }\n\n /**\n * Add a heatmap layer bound to an existing source. `maxzoom` controls the\n * zoom at which the heatmap fades out in favour of individual-point layers.\n */\n public addHeatmapLayer(config: { id: string; source: string; maxzoom?: number; paint: mapboxgl.HeatmapLayerSpecification['paint'] }): void {\n this.map.addLayer({\n id: config.id,\n type: 'heatmap',\n source: config.source,\n maxzoom: config.maxzoom,\n paint: config.paint,\n });\n }\n\n /**\n * Apply a Mapbox filter expression to a layer, or pass `null` to clear it.\n * Silently no-ops if the layer doesn't exist.\n */\n public setFilter(layerId: string, filter: unknown[] | null): void {\n if (this.map.getLayer(layerId)) {\n this.map.setFilter(layerId, filter as mapboxgl.FilterSpecification | null);\n }\n }\n\n /**\n * Change a paint property on any layer (color, opacity, width, etc.).\n * Works on layers from the base style as well as layers you've added.\n * Silently no-ops when the layer is missing so style swaps don't throw.\n *\n * @example\n * map.setPaintProperty('road-primary', 'line-color', '#ff0080');\n * map.setPaintProperty('water', 'fill-opacity', 0.6);\n */\n public setPaintProperty(layerId: string, name: string, value: unknown): void {\n if (this.map.getLayer(layerId)) {\n (this.map.setPaintProperty as (id: string, name: string, value: unknown) => void)(\n layerId,\n name,\n value,\n );\n }\n }\n\n /**\n * Change a layout property on any layer (visibility, icon-image, text-field, etc.).\n *\n * @example\n * map.setLayoutProperty('poi-label', 'visibility', 'none');\n * map.setLayoutProperty('road-label', 'text-size', 14);\n */\n public setLayoutProperty(layerId: string, name: string, value: unknown): void {\n if (this.map.getLayer(layerId)) {\n (this.map.setLayoutProperty as (id: string, name: string, value: unknown) => void)(\n layerId,\n name,\n value,\n );\n }\n }\n\n /**\n * Return every layer id currently in the style.\n * Useful for discovering layer names from a custom Studio style so you can target them at runtime.\n */\n public getLayerIds(): string[] {\n return this.map.getStyle().layers.map((l) => l.id);\n }\n\n /** `true` when a layer with this id exists in the current style. */\n public hasLayer(id: string): boolean {\n return !!this.map.getLayer(id);\n }\n\n /** `true` when a source with this id exists. */\n public hasSource(id: string): boolean {\n return !!this.map.getSource(id);\n }\n\n /** Remove a layer if present. Useful during style swaps or layer teardown. */\n public safeRemoveLayer(id: string): void {\n if (this.hasLayer(id)) {\n this.map.removeLayer(id);\n }\n }\n\n /** Convert geographic coordinates into pixel coordinates within the map container. */\n public project(lngLat: mapboxgl.LngLatLike): mapboxgl.Point {\n return this.map.project(lngLat);\n }\n\n /**\n * Register an image for use with `icon-image` in symbol layers. Accepts\n * either a pre-loaded `HTMLImageElement` or a URL to fetch. Updates an\n * existing entry when the id is already registered.\n */\n public async addImage(id: string, img: HTMLImageElement | string): Promise<void> {\n const imgEl = typeof img === 'string' ? await this.loadImage(img) : img;\n\n if (!this.map.hasImage(id)) {\n this.map.addImage(id, imgEl, { sdf: false });\n\n return;\n }\n\n this.map.updateImage(id, imgEl);\n }\n\n /**\n * Register `image` under `id`, replacing any image already there. Unlike `addImage`'s in-place update, the size and\n * the options (`pixelRatio`, `stretchX` / `stretchY`, `content`) may change, as a re-baked canvas sprite needs.\n */\n public replaceImage(id: string, image: MapImageSource, options?: MapImageOptions): void {\n if (this.map.hasImage(id)) {\n this.map.removeImage(id);\n }\n\n this.map.addImage(id, image, options);\n }\n\n /** Flip a layer's `visibility` between `'visible'` and `'none'`. */\n public toggleLayerVisibility(layerId: string): void {\n const vis = this.map.getLayoutProperty(layerId, 'visibility');\n\n this.map.setLayoutProperty(\n layerId,\n 'visibility',\n vis === 'visible' ? 'none' : 'visible',\n );\n }\n\n /**\n * Subscribe to a raw Mapbox event. Supports both the two-arg form\n * (`on(event, handler)`) and the layer-scoped form (`on(event, layerId, handler)`).\n */\n public on(event: string, ...args: unknown[]): void {\n (this.map as unknown as { on: (e: string, ...a: unknown[]) => void }).on(event, ...args);\n }\n\n /** Remove an event listener previously registered with `on`. */\n public off(event: string, ...args: unknown[]): void {\n (this.map as unknown as { off: (e: string, ...a: unknown[]) => void }).off(event, ...args);\n }\n\n /** Remove a source from the style. Remove any layers using it first. */\n public removeSource(id: string): void {\n this.map.removeSource(id);\n }\n\n /** Set arbitrary feature-state for a feature in a GeoJSON source. */\n public setFeatureState(\n sourceId: string,\n featureId: number | string,\n state: Record<string, unknown>,\n ): void {\n if (!this.map.getSource(sourceId)) {\n return;\n }\n\n this.map.setFeatureState({ source: sourceId, id: featureId }, state);\n }\n\n /** Remove a specific feature-state key, or all state for the feature when `key` is omitted. */\n public clearFeatureState(sourceId: string, featureId: number | string, key?: string): void {\n if (!this.map.getSource(sourceId)) {\n return;\n }\n\n if (!key) {\n this.map.removeFeatureState({ source: sourceId, id: featureId });\n\n return;\n }\n\n this.map.setFeatureState({ source: sourceId, id: featureId }, { [key]: false });\n }\n\n /**\n * Enter polygon-drawing mode. Lazily mounts a `@mapbox/mapbox-gl-draw` control,\n * hides its default UI (consumer controls the toggle), and switches to `draw_polygon`.\n * The user clicks vertices and double-clicks (or clicks the first vertex) to close.\n * The completed polygon is emitted on `polygonCreate`.\n */\n public enableDrawPolygon(): void {\n if (!this.draw) {\n this.draw = new MapboxDraw({\n displayControlsDefault: false,\n controls: {},\n });\n\n this.map.addControl(this.draw);\n }\n\n if (!this.onDrawCreate) {\n this.onDrawCreate = (e) => {\n const polygon = e.features.find(\n (f) => f.geometry.type === 'Polygon',\n ) as GeoJSON.Feature<GeoJSON.Polygon> | undefined;\n\n if (polygon) {\n this.polygonCreate.next(polygon);\n }\n };\n\n (this.map as unknown as { on: (e: string, h: unknown) => void }).on(\n 'draw.create',\n this.onDrawCreate,\n );\n }\n\n this.lockInteractions();\n\n this.draw.changeMode('draw_polygon');\n }\n\n /** Exit polygon-drawing mode and remove any in-progress or drawn polygons. */\n public disableDrawPolygon(): void {\n if (this.onDrawCreate) {\n (this.map as unknown as { off: (e: string, h: unknown) => void }).off(\n 'draw.create',\n this.onDrawCreate,\n );\n this.onDrawCreate = undefined;\n }\n\n if (this.draw) {\n this.draw.deleteAll();\n this.map.removeControl(this.draw);\n this.draw = undefined;\n }\n\n this.unlockInteractions();\n }\n\n /**\n * Disable pan/zoom handlers so the viewport stays fixed while the user draws.\n * Saves the prior enabled-state for each handler so it can be restored by\n * `unlockInteractions`. Safe to call repeatedly — a second call is a no-op\n * because saved state is only captured on the first lock.\n */\n private lockInteractions(): void {\n if (this.savedInteractions) {\n return;\n }\n\n this.savedInteractions = {\n dragPan: this.map.dragPan.isEnabled(),\n scrollZoom: this.map.scrollZoom.isEnabled(),\n boxZoom: this.map.boxZoom.isEnabled(),\n doubleClickZoom: this.map.doubleClickZoom.isEnabled(),\n touchZoomRotate: this.map.touchZoomRotate.isEnabled(),\n keyboard: this.map.keyboard.isEnabled(),\n };\n\n this.map.dragPan.disable();\n this.map.scrollZoom.disable();\n this.map.boxZoom.disable();\n this.map.doubleClickZoom.disable();\n this.map.touchZoomRotate.disable();\n this.map.keyboard.disable();\n }\n\n /**\n * Restore every pan/zoom handler to the enabled-state captured by\n * `lockInteractions`. No-op when interactions were never locked.\n */\n private unlockInteractions(): void {\n if (!this.savedInteractions) {\n return;\n }\n\n const prev = this.savedInteractions;\n\n if (prev.dragPan) this.map.dragPan.enable();\n if (prev.scrollZoom) this.map.scrollZoom.enable();\n if (prev.boxZoom) this.map.boxZoom.enable();\n if (prev.doubleClickZoom) this.map.doubleClickZoom.enable();\n if (prev.touchZoomRotate) this.map.touchZoomRotate.enable();\n if (prev.keyboard) this.map.keyboard.enable();\n\n this.savedInteractions = undefined;\n }\n\n /** Remove every polygon the user has drawn, keeping draw mode active. */\n public clearDrawnPolygons(): void {\n this.draw?.deleteAll();\n }\n\n\n /** `isStyleLoaded()` also waits for tiles; what addSource needs is mapbox's one-shot \"style parsed\" flag. */\n private isStyleParsed(): boolean {\n return this.map.isStyleLoaded() || !!(this.map as unknown as { style?: { _loaded?: boolean } }).style?._loaded;\n }\n\n /** Fetch a URL into an `HTMLImageElement`. Resolves on `load`, rejects on `error`. */\n private loadImage(url: string): Promise<HTMLImageElement> {\n return new Promise((res, rej) => {\n const img = new Image();\n\n img.onload = () => res(img);\n img.onerror = rej;\n img.src = url;\n });\n }\n\n}\n","import { isPlatformBrowser } from '@angular/common';\nimport {\n ChangeDetectionStrategy,\n Component,\n DestroyRef,\n ElementRef,\n PLATFORM_ID,\n ViewEncapsulation,\n effect,\n inject,\n input,\n output,\n viewChild,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\n\nimport type mapboxgl from 'mapbox-gl';\nimport type { StyleSpecification } from 'mapbox-gl';\n\nimport { MapboxService } from '../mapbox.service';\n\n/**\n * Thin host component that mounts a Mapbox map into a container div, forwards\n * lifecycle/events from `MapboxService`, and cleans up on destroy.\n *\n * Consumers interact with the underlying map via the public `map` (MapboxService)\n * instance — use `viewChild(ApexMapComponent)` in a parent to reach `component.map`\n * and call `addSource()`, `addLayer()`, `moveCenter()`, etc.\n *\n * Example:\n * <apex-map [center]=\"[-80.84, 35.22]\" [zoom]=\"11\" (mapReady)=\"onReady()\"/>\n */\n\n@Component({\n selector: 'apex-map',\n standalone: true,\n templateUrl: './apex-map.component.html',\n styleUrls: ['./apex-map.component.css'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n})\n\nexport class ApexMapComponent {\n\n public center = input<[number, number]>([-80.8431, 35.2271]);\n public zoom = input<number>(10);\n public mapStyle = input<string | StyleSpecification | undefined>(undefined);\n public maxBounds = input<mapboxgl.LngLatBoundsLike | undefined>(undefined);\n public showNavigation = input<boolean>(true);\n\n public mapReady = output<void>();\n public mapClick = output<mapboxgl.MapMouseEvent>();\n public featureClick = output<mapboxgl.MapMouseEvent>();\n\n readonly map = inject(MapboxService);\n\n private readonly platformId = inject(PLATFORM_ID);\n private readonly destroyRef = inject(DestroyRef);\n private readonly container = viewChild.required<ElementRef<HTMLElement>>('container');\n\n /**\n * Wire a reactive effect that emits `mapReady` once the underlying Mapbox\n * `load` event fires and `MapboxService.ready()` flips to `true`.\n */\n constructor() {\n effect(() => {\n if (this.map.ready()) {\n this.mapReady.emit();\n }\n });\n }\n\n /**\n * Initialise the Mapbox instance into the `#container` div, forward\n * `mapClick`/`featureClick` streams as component outputs, and register\n * teardown so the map is destroyed with the component.\n * No-op on non-browser platforms (SSR).\n */\n public ngAfterViewInit(): void {\n if (!isPlatformBrowser(this.platformId)) {\n return;\n }\n\n this.map.init({\n container: this.container().nativeElement,\n center: this.center(),\n zoom: this.zoom(),\n mapStyle: this.mapStyle(),\n maxBounds: this.maxBounds(),\n showNavigation: this.showNavigation(),\n });\n\n this.map.mapClick\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe((e) => this.mapClick.emit(e));\n\n this.map.featureClick\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe((e) => this.featureClick.emit(e));\n\n this.destroyRef.onDestroy(() => this.map.deactivate(this.container().nativeElement));\n }\n\n}\n","<div #container class=\"apex-map__container\"></div>\n","import type mapboxgl from 'mapbox-gl';\nimport type { Position } from 'geojson';\n\ntype Coord = [number, number];\n\n/**\n * Recursively flatten any nesting of GeoJSON coordinates down to a flat list of [lng, lat] pairs.\n * Handles Point, LineString, Polygon, and MultiPolygon coordinate shapes uniformly.\n */\nexport function flattenCoords(arr: Position | Position[] | Position[][] | Position[][][]): Coord[] {\n const out: Coord[] = [];\n\n const recurse = (node: unknown): void => {\n if (\n Array.isArray(node) &&\n typeof node[0] === 'number' &&\n typeof node[1] === 'number'\n ) {\n out.push(node as Coord);\n } else if (Array.isArray(node)) {\n node.forEach(recurse);\n }\n };\n\n recurse(arr);\n\n return out;\n}\n\n/**\n * Compute the [[minLng, minLat], [maxLng, maxLat]] bounds of a flat list of coordinates.\n * Return value is compatible with `mapboxgl.LngLatBoundsLike`.\n */\nexport function calculateBounds(coords: Coord[]): mapboxgl.LngLatBoundsLike {\n let minX = 180;\n let minY = 90;\n let maxX = -180;\n let maxY = -90;\n\n coords.forEach(([lng, lat]) => {\n if (lng < minX) minX = lng;\n if (lng > maxX) maxX = lng;\n if (lat < minY) minY = lat;\n if (lat > maxY) maxY = lat;\n });\n\n return [\n [minX, minY],\n [maxX, maxY],\n ];\n}\n\n/**\n * Build a closed square polygon of side `2 * radiusKm` centered at `center`.\n * Useful when you need a small viewport-like polygon for point-in-polygon queries.\n */\nexport function calculateViewportPolygonFromCenter(center: Coord, radiusKm = 0.5): number[][][] {\n const [lng, lat] = center;\n\n const degreesPerMeterLng = 1 / (111320 * Math.cos((lat * Math.PI) / 180));\n const degreesPerMeterLat = 1 / 110540;\n\n const radiusMeters = radiusKm * 1000;\n const lngDelta = radiusMeters * degreesPerMeterLng;\n const latDelta = radiusMeters * degreesPerMeterLat;\n\n return [\n [\n [lng - lngDelta, lat - latDelta],\n [lng + lngDelta, lat - latDelta],\n [lng + lngDelta, lat + latDelta],\n [lng - lngDelta, lat + latDelta],\n [lng - lngDelta, lat - latDelta],\n ],\n ];\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;AAeA;;;;;;;;;;;;AAYG;AAEH;AACA;AACA;AACA,MAAM,UAAU,GAAG,IAAI,GAAG,EAAuC;MAGpD,aAAa,CAAA;AAD1B,IAAA,WAAA,GAAA;;AAIS,QAAA,IAAA,CAAA,QAAQ,GAAG,IAAI,OAAO,EAA0B;;AAGhD,QAAA,IAAA,CAAA,YAAY,GAAG,IAAI,OAAO,EAA0B;;AAGpD,QAAA,IAAA,CAAA,aAAa,GAAG,IAAI,OAAO,EAAoC;AAErD,QAAA,IAAA,CAAA,MAAM,GAAG,MAAM,CAAU,KAAK,kDAAC;;AAGhC,QAAA,IAAA,CAAA,KAAK,GAAoB,IAAI,CAAC,MAAM;;AAGpC,QAAA,IAAA,CAAA,MAAM,GAAG,MAAM,CAA0B,IAAI,kDAAC;;AAG9C,QAAA,IAAA,CAAA,IAAI,GAAG,MAAM,CAAgB,IAAI,gDAAC;;AAGlC,QAAA,IAAA,CAAA,MAAM,GAAG,MAAM,CAA8C,IAAI,kDAAC;;AAGlE,QAAA,IAAA,CAAA,QAAQ,GAAG,MAAM,CAAU,KAAK,oDAAC;;;QAKzC,IAAA,CAAA,cAAc,GAAG,KAAK;AAEb,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Q,GAAG,GAAG,EAAA;AAC9E,IAAA,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,MAAM;IAEzB,MAAM,kBAAkB,GAAG,CAAC,IAAI,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC;AACzE,IAAA,MAAM,kBAAkB,GAAG,CAAC,GAAG,MAAM;AAErC,IAAA,MAAM,YAAY,GAAG,QAAQ,GAAG,IAAI;AACpC,IAAA,MAAM,QAAQ,GAAG,YAAY,GAAG,kBAAkB;AAClD,IAAA,MAAM,QAAQ,GAAG,YAAY,GAAG,kBAAkB;IAElD,OAAO;AACL,QAAA;AACE,YAAA,CAAC,GAAG,GAAG,QAAQ,EAAE,GAAG,GAAG,QAAQ,CAAC;AAChC,YAAA,CAAC,GAAG,GAAG,QAAQ,EAAE,GAAG,GAAG,QAAQ,CAAC;AAChC,YAAA,CAAC,GAAG,GAAG,QAAQ,EAAE,GAAG,GAAG,QAAQ,CAAC;AAChC,YAAA,CAAC,GAAG,GAAG,QAAQ,EAAE,GAAG,GAAG,QAAQ,CAAC;AAChC,YAAA,CAAC,GAAG,GAAG,QAAQ,EAAE,GAAG,GAAG,QAAQ,CAAC;AACjC,SAAA;KACF;AACH;;AC3EA;;AAEG;;;;"}
1
+ {"version":3,"file":"apexara-map.mjs","sources":["../../../../projects/apexara/map/src/lib/mapbox.service.ts","../../../../projects/apexara/map/src/lib/apex-map/apex-map.component.ts","../../../../projects/apexara/map/src/lib/apex-map/apex-map.component.html","../../../../projects/apexara/map/src/lib/apex-map-pinch-zoom.directive.ts","../../../../projects/apexara/map/src/lib/map-user-location.layer.ts","../../../../projects/apexara/map/src/lib/map.utils.ts","../../../../projects/apexara/map/apexara-map.ts"],"sourcesContent":["import { isPlatformBrowser } from '@angular/common';\nimport { DestroyRef, Injectable, PLATFORM_ID, Signal, WritableSignal, inject, signal } from '@angular/core';\n\nimport { Subject } from 'rxjs';\n\nimport MapboxDraw from '@mapbox/mapbox-gl-draw';\nimport mapboxgl, { CameraOptions, EasingOptions, LayerSpecification, PaddingOptions } from 'mapbox-gl';\n\nimport { MAP_CONFIG, MapStyles } from '@apexara/map/config';\n\nimport type * as GeoJSON from 'geojson';\nimport type { Position } from 'geojson';\n\nimport {\n MapDrawOptions,\n MapEventData,\n MapFeatureQuery,\n MapFitOptions,\n MapImageOptions,\n MapImageSource,\n MapInitOptions,\n MapInsets,\n MapQueryGeometry,\n MapStyleOptions,\n SourceConfig,\n} from './map.types';\n\n/**\n * Mapbox Service — wrapper around a `mapboxgl.Map` instance.\n *\n * Terms:\n * - Feature: A GeoJSON geometry (Point/LineString/Polygon/…) drawn on the map.\n * - Properties: Arbitrary key-value pairs on `feature.properties`.\n * - Source: Raw data (GeoJSON, vector tiles, raster tiles) added with `addSource`.\n * - Layer: A visual rendering (circle, fill, heatmap, raster, …) bound to a source.\n * - Cluster: A grouped feature emitted when `cluster: true` is set on a GeoJSON source.\n *\n * Browser-only: `init()` is a no-op on the server. Methods other than `init()` assume\n * the map instance exists and must only be called after `ready()` becomes true.\n */\n\n// Process-lifetime cache of parsed Mapbox style JSON keyed by URL. Subsequent\n// inits with the same URL pass the cached object to the Map constructor\n// instead of re-fetching `api.mapbox.com/styles/v1/...`.\nconst styleCache = new Map<string, mapboxgl.StyleSpecification>();\n\n@Injectable({ providedIn: 'root' })\nexport class MapboxService {\n\n /** Click on empty canvas (no features under the cursor). Event stream. */\n public mapClick = new Subject<mapboxgl.MapMouseEvent>();\n\n /** Click on a feature (wired by consumers via `on('click', layerId, ...)`). Event stream. */\n public featureClick = new Subject<mapboxgl.MapMouseEvent>();\n\n /** Fires when the user completes a polygon in draw mode (double-click or first-vertex click). */\n public polygonCreate = new Subject<GeoJSON.Feature<GeoJSON.Polygon>>();\n\n private readonly _ready = signal<boolean>(false);\n\n /** Reactive state: `true` once the map's `load` event has fired. */\n public readonly ready: Signal<boolean> = this._ready;\n\n /** Reactive state: current center `[lng, lat]`. Updates on `moveend`. `null` before init. */\n public readonly center = signal<[number, number] | null>(null);\n\n /** Reactive state: current zoom level. Updates on `moveend`. `null` before init. */\n public readonly zoom = signal<number | null>(null);\n\n /** Reactive state: current viewport bounds `[[swLng, swLat], [neLng, neLat]]`. Updates on `moveend`. */\n public readonly bounds = signal<[[number, number], [number, number]] | null>(null);\n\n /** Reactive state: `true` while the map is panning/zooming (between `movestart` and `moveend`). */\n public readonly isMoving = signal<boolean>(false);\n\n private map!: mapboxgl.Map;\n // `map` stays non-null-typed so existing call-sites don't need guards;\n // this flag tracks whether the constructor has actually run.\n private mapInitialised = false;\n private draw?: MapboxDraw;\n private readonly config = inject(MAP_CONFIG);\n private readonly platformId = inject(PLATFORM_ID);\n\n private onDrawCreate?: (e: { features: GeoJSON.Feature[] }) => void;\n private savedInteractions?: Record<'dragPan' | 'scrollZoom' | 'boxZoom' | 'doubleClickZoom' | 'touchZoomRotate' | 'keyboard', boolean>;\n\n // mapbox-gl is given this stable element (not the consumer's `<div>`).\n // The service re-parents `hostDiv` between consumer containers on context\n // swaps so the underlying `mapboxgl.Map` survives → one billed load per session.\n private hostDiv: HTMLDivElement | null = null;\n\n private containerStack: HTMLElement[] = [];\n\n private readonly _activeContainer: WritableSignal<HTMLElement | null> = signal(null);\n public readonly activeContainer: Signal<HTMLElement | null> = this._activeContainer;\n\n // Whether this browser can run mapbox; null until asked. Kept, since mapbox's check builds a worker and a canvas.\n private supported: boolean | null = null;\n\n // What `fitBounds` has always done: 40 px all round, a one-second slide.\n private readonly fitDefaults: MapFitOptions = { padding: 40, duration: 1000 };\n\n /** Back-compat wrapper around `activate`. SSR-safe. */\n public async init(options: MapInitOptions): Promise<void> {\n if (!isPlatformBrowser(this.platformId)) {\n return;\n }\n this.activate(options.container, options);\n }\n\n /** Whether this browser can run mapbox (WebGL2, workers, canvas reads). Asked once; false on the server. */\n public isSupported(): boolean {\n this.supported ??= isPlatformBrowser(this.platformId) && mapboxgl.supported();\n\n return this.supported;\n }\n\n /**\n * Puts the shared map on `container`. False when it did not start there: on the server, in a browser that cannot run\n * mapbox, or when the first start throws (undone and reported). A running map's errors still throw.\n */\n public activate(container: HTMLElement, options: MapInitOptions): boolean {\n if (!this.isSupported()) {\n return false;\n }\n\n if (!this.mapInitialised) {\n return this.startMap(container, options);\n }\n\n const active = this._activeContainer();\n\n if (active === container) {\n if (options.center) {\n this.map.jumpTo({ center: options.center, zoom: options.zoom ?? this.map.getZoom() });\n }\n requestAnimationFrame(() => this.map.resize());\n\n return true;\n }\n\n this.hostDiv?.remove();\n if (this.hostDiv) {\n this.hostDiv.style.display = '';\n container.appendChild(this.hostDiv);\n }\n\n this.containerStack = this.containerStack.filter((c) => c !== container);\n this.containerStack.push(container);\n this._activeContainer.set(container);\n\n if (options.center) {\n this.map.jumpTo({ center: options.center, zoom: options.zoom ?? this.map.getZoom() });\n }\n requestAnimationFrame(() => this.map.resize());\n\n return true;\n }\n\n public deactivate(container: HTMLElement): void {\n if (!isPlatformBrowser(this.platformId)) {\n return;\n }\n\n const wasActive = this._activeContainer() === container;\n this.containerStack = this.containerStack.filter((c) => c !== container);\n\n if (!wasActive) {\n return;\n }\n\n const next = this.containerStack[this.containerStack.length - 1];\n\n this.hostDiv?.remove();\n\n if (next && this.hostDiv) {\n this.hostDiv.style.display = '';\n next.appendChild(this.hostDiv);\n this._activeContainer.set(next);\n requestAnimationFrame(() => this.map.resize());\n return;\n }\n\n if (this.hostDiv) {\n document.body.appendChild(this.hostDiv);\n this.hostDiv.style.display = 'none';\n }\n this._activeContainer.set(null);\n }\n\n // The first start. It can pass isSupported and still throw (e.g. at the browser's limit of WebGL contexts) after its\n // host div went into the container: the div comes back out, so the container is left as it was.\n private startMap(container: HTMLElement, options: MapInitOptions): boolean {\n try {\n this.createMap(container, options);\n } catch (error) {\n this.hostDiv?.remove();\n this.hostDiv = null;\n console.error('[@apexara/map] The map failed to start.', error);\n\n return false;\n }\n\n this.containerStack.push(container);\n this._activeContainer.set(container);\n\n return true;\n }\n\n private createMap(container: HTMLElement, options: MapInitOptions): void {\n const defaultBounds: mapboxgl.LngLatBoundsLike = [\n [-175, -85],\n [175, 85],\n ];\n\n const styleInput = options.mapStyle || this.config.defaultStyle || MapStyles.Streets;\n const styleUrl = typeof styleInput === 'string' ? styleInput : null;\n const cachedStyle = styleUrl ? styleCache.get(styleUrl) : undefined;\n\n this.hostDiv = document.createElement('div');\n this.hostDiv.style.cssText = 'position:absolute;inset:0;width:100%;height:100%;';\n container.appendChild(this.hostDiv);\n\n this.map = new mapboxgl.Map({\n center: options.center,\n zoom: options.zoom || 10,\n accessToken: this.config.accessToken,\n container: this.hostDiv,\n style: (cachedStyle ?? styleInput) as string,\n fadeDuration: 0,\n pitch: 0,\n bearing: 0,\n dragRotate: false,\n pitchWithRotate: false,\n projection: 'mercator',\n maxBounds: options.maxBounds ?? defaultBounds,\n renderWorldCopies: false,\n // Required for `canvas.toDataURL()` to return pixels — consumers that\n // snapshot the canvas (e.g. freeze-frame overlays) rely on this.\n preserveDrawingBuffer: true,\n });\n this.mapInitialised = true;\n\n if (styleUrl && !cachedStyle) {\n this.map.once('style.load', () => {\n styleCache.set(styleUrl, this.map.getStyle() as mapboxgl.StyleSpecification);\n });\n }\n\n this.center.set(options.center);\n this.zoom.set(options.zoom ?? 10);\n\n this.map.on('movestart', () => this.isMoving.set(true));\n\n this.map.on('moveend', () => {\n const c = this.map.getCenter();\n const b = this.map.getBounds() as mapboxgl.LngLatBounds;\n const sw = b.getSouthWest();\n const ne = b.getNorthEast();\n\n this.center.set([c.lng, c.lat]);\n this.zoom.set(this.map.getZoom());\n this.bounds.set([[sw.lng, sw.lat], [ne.lng, ne.lat]]);\n this.isMoving.set(false);\n });\n\n this.map.once('load', () => {\n if (options.showNavigation !== false) {\n this.map.addControl(\n new mapboxgl.NavigationControl({ showCompass: false, showZoom: true }),\n );\n }\n\n this._ready.set(true);\n });\n }\n\n /** Current map center as a `LngLat`. Prefer the `center` signal for reactive reads. */\n public getCenter(): mapboxgl.LngLat {\n return this.map.getCenter();\n }\n\n /** Current zoom level. Prefer the `zoom` signal for reactive reads. */\n public getZoom(): number {\n return this.map.getZoom();\n }\n\n /** The live `mapboxgl.Map`, for mapbox APIs this service does not wrap. `undefined` until the first `init`/`activate`. */\n public getMap(): mapboxgl.Map | undefined {\n return this.mapInitialised ? this.map : undefined;\n }\n\n /**\n * Resolves once the style is parsed, so sources and layers can be added: after a re-parent `ready()` (a one-time\n * latch) says nothing about that. Resolves at once with no map; pass `destroyRef` to resolve on teardown, not hang.\n */\n public whenStyleReady(destroyRef?: DestroyRef): Promise<void> {\n if (!this.mapInitialised || this.isStyleParsed()) {\n return Promise.resolve();\n }\n\n return new Promise((resolve) => {\n let removeDestroyHook: (() => void) | undefined;\n\n const done = (): void => {\n this.map.off('style.load', done);\n this.map.off('idle', done);\n removeDestroyHook?.();\n resolve();\n };\n\n // `idle` always fires once the map settles, so a `style.load` that already fired cannot hang the wait.\n this.map.once('style.load', done);\n this.map.once('idle', done);\n removeDestroyHook = destroyRef?.onDestroy(done);\n });\n }\n\n /**\n * Return the current viewport as a closed GeoJSON-style polygon ring\n * (`[sw, se, ne, nw, sw]`). Useful for point-in-polygon queries against the\n * visible area.\n */\n public getViewportPolygon(): Position[][] {\n const bounds = this.map.getBounds() as mapboxgl.LngLatBounds;\n\n const sw = bounds.getSouthWest();\n const se = bounds.getSouthEast();\n const ne = bounds.getNorthEast();\n const nw = bounds.getNorthWest();\n\n return [\n [\n [sw.lng, sw.lat],\n [se.lng, se.lat],\n [ne.lng, ne.lat],\n [nw.lng, nw.lat],\n [sw.lng, sw.lat],\n ],\n ];\n }\n\n /**\n * Extract `properties` from the first feature under a click/hover event,\n * cast to `T`. Returns `undefined` when no feature was hit or it has no props.\n */\n public getFeatureProperties<T>(mouseEvent: mapboxgl.MapMouseEvent): T | undefined {\n const feature = mouseEvent.features?.[0];\n\n if (!feature) {\n return undefined;\n }\n\n const properties = feature.properties;\n\n if (!properties) {\n return undefined;\n }\n\n return properties as T;\n }\n\n /**\n * Expand a cluster into its individual leaf features (up to `limit`, paginated\n * via `offset`). Rejects if `sourceId` is missing or not a clustered GeoJSON source.\n */\n public async getClusterProperties(\n sourceId: string,\n clusterId: number,\n limit = 10000,\n offset = 0,\n ): Promise<mapboxgl.GeoJSONFeature[]> {\n return new Promise((resolve, reject) => {\n const src = this.clusterSourceOf(sourceId);\n\n if (!src) {\n reject(this.notClusteredError(sourceId));\n\n return;\n }\n\n src.getClusterLeaves(clusterId, limit, offset, (err, features) => {\n if (err) {\n reject(err);\n } else {\n resolve(features as mapboxgl.GeoJSONFeature[]);\n }\n });\n });\n }\n\n /**\n * The zoom at which a cluster splits into its children, e.g. to `easeTo` it. Rejects as `getClusterProperties` does,\n * and when mapbox answers with no zoom.\n */\n public getClusterExpansionZoom(sourceId: string, clusterId: number): Promise<number> {\n return new Promise((resolve, reject) => {\n const source = this.clusterSourceOf(sourceId);\n\n if (!source) {\n reject(this.notClusteredError(sourceId));\n\n return;\n }\n\n source.getClusterExpansionZoom(clusterId, (error, expansionZoom) => {\n if (error) {\n reject(error);\n } else if (typeof expansionZoom !== 'number') {\n reject(new Error(`Cluster ${clusterId} in source '${sourceId}' gave no expansion zoom.`));\n } else {\n resolve(expansionZoom);\n }\n });\n });\n }\n\n /**\n * Features rendered at a screen point or in a `[corner, corner]` box (the whole viewport when `geometry` is\n * undefined), kept to `layers` and `filter`. Returns `[]` when the map has not been initialised yet.\n */\n public getRenderedFeatures(geometry?: MapQueryGeometry, query?: MapFeatureQuery): mapboxgl.GeoJSONFeature[] {\n return this.map ? this.map.queryRenderedFeatures(geometry as MapQueryGeometry, query) : [];\n }\n\n /** Whether `lngLat` projects inside the canvas, `insets` pixels in from its edges. False before the map exists. */\n public isPointOnScreen(lngLat: mapboxgl.LngLatLike, insets: MapInsets = 0): boolean {\n if (!this.mapInitialised) {\n return false;\n }\n\n const point = this.map.project(lngLat);\n const canvas = this.map.getCanvas();\n\n return point.x >= this.insetOf(insets, 'left')\n && point.y >= this.insetOf(insets, 'top')\n && point.x <= canvas.clientWidth - this.insetOf(insets, 'right')\n && point.y <= canvas.clientHeight - this.insetOf(insets, 'bottom');\n }\n\n /** Whether the shared map is on screen inside `element`: its active container is `element` or below it. */\n public isShownIn(element: Node): boolean {\n const active = this._activeContainer();\n\n return active !== null && element.contains(active);\n }\n\n /**\n * Swap the base style. `{ diff: false }` rebuilds it from scratch, for a swap where mapbox's diff keeps a source the\n * rebuild then trips over. Custom sources/layers you added must be re-applied after `styledata`.\n */\n public setStyle(styleUrl: string, options?: MapStyleOptions): void {\n const cachedStyle = styleCache.get(styleUrl);\n\n // The typings mark mapbox's optional font options as required.\n this.map.setStyle((cachedStyle ?? styleUrl) as string, options as Parameters<mapboxgl.Map['setStyle']>[1]);\n\n if (!cachedStyle) {\n this.map.once('style.load', () => {\n styleCache.set(styleUrl, this.map.getStyle() as mapboxgl.StyleSpecification);\n });\n }\n }\n\n /** Animate the camera to `center` at the given zoom (default 13). `flyTo` takes a duration, a curve and event data. */\n public moveCenter(center: [number, number], zoom = 13): void {\n this.map.flyTo({ center, zoom });\n }\n\n /**\n * Fit the viewport to `bounds`. A number is the padding (default 40) of a one-second slide; options (`padding` per\n * side, `maxZoom`, `duration`, `animate: false`, …) lay over those same defaults. `eventData` reaches the move's events.\n */\n public fitBounds(bounds: mapboxgl.LngLatBoundsLike, options: number | MapFitOptions = {}, eventData?: MapEventData): void {\n const overrides = typeof options === 'number' ? { padding: options } : options;\n\n this.map.fitBounds(bounds, { ...this.fitDefaults, ...overrides }, eventData);\n }\n\n /** Fly the camera (mapbox's `flyTo`: `center`, `zoom`, `duration`, `curve`, `offset`, …). */\n public flyTo(options: EasingOptions, eventData?: MapEventData): void {\n this.map.flyTo(options, eventData);\n }\n\n /** Ease the camera (mapbox's `easeTo`), e.g. into a cluster's expansion zoom. */\n public easeTo(options: EasingOptions, eventData?: MapEventData): void {\n this.map.easeTo(options, eventData);\n }\n\n /** Move the camera at once (mapbox's `jumpTo`). */\n public jumpTo(options: CameraOptions, eventData?: MapEventData): void {\n this.map.jumpTo(options, eventData);\n }\n\n /**\n * Have mapbox re-read its container's size, e.g. from a `ResizeObserver`. A resize fires `movestart` / `moveend`, which\n * carry `eventData`. No-op before the map exists.\n */\n public resize(eventData?: MapEventData): void {\n if (this.mapInitialised) {\n this.map.resize(eventData);\n }\n }\n\n /**\n * Add a GeoJSON source. Pass `clustered: true` and optional `clusterRadius`/`clusterMaxZoom`\n * for point clustering. Set `generateId: true` when you plan to use feature-state.\n */\n public addSource(config: SourceConfig): void {\n const src: mapboxgl.GeoJSONSourceSpecification = {\n type: 'geojson',\n data: config.data,\n };\n\n if (config.clustered !== undefined) {\n src.cluster = config.clustered;\n }\n\n if (config.clusterRadius !== undefined) {\n src.clusterRadius = config.clusterRadius;\n }\n\n if (config.clusterMaxZoom !== undefined) {\n src.clusterMaxZoom = config.clusterMaxZoom;\n }\n\n if (config.generateId !== undefined) {\n src.generateId = config.generateId;\n }\n\n this.map.addSource(config.id, src);\n }\n\n /**\n * Add a GeoJSON source, or replace the data of the one already under `config.id` (its other options stay as they\n * were). True when it was added, so the caller adds the layers that draw it.\n */\n public upsertSource(config: SourceConfig): boolean {\n if (this.hasSource(config.id)) {\n this.updateSource(config.id, config.data);\n\n return false;\n }\n\n this.addSource(config);\n\n return true;\n }\n\n /** Replace the data of an existing GeoJSON source in place. No-op if the source is missing. */\n public updateSource(id: string, data: string | GeoJSON.GeoJSON): void {\n const source = this.map.getSource(id);\n\n if (source && 'setData' in source) {\n (source as mapboxgl.GeoJSONSource).setData(data);\n }\n }\n\n /**\n * Add a layer to the style. Pass `beforeId` to insert the new layer beneath\n * an existing one (useful for controlling draw order against style layers).\n */\n public addLayer(layer: LayerSpecification, beforeId?: string): void {\n if (beforeId) {\n this.map.addLayer(layer, beforeId);\n } else {\n this.map.addLayer(layer);\n }\n }\n\n /**\n * Add a raster layer backed by a source with the same id. Starts hidden —\n * toggle with `toggleLayerVisibility(id)` or `setLayoutProperty`.\n */\n public addRasterLayer(id: string, _url: string): void {\n this.map.addLayer({\n id,\n type: 'raster',\n source: id,\n layout: { visibility: 'none' },\n });\n }\n\n /** Add a vector tile source from a TileJSON URL (typically `mapbox://...`). */\n public addVectorSource(id: string, url: string): void {\n this.map.addSource(id, {\n type: 'vector',\n url,\n } as mapboxgl.VectorSourceSpecification);\n }\n\n /**\n * Add a heatmap layer bound to an existing source. `maxzoom` controls the\n * zoom at which the heatmap fades out in favour of individual-point layers.\n */\n public addHeatmapLayer(config: { id: string; source: string; maxzoom?: number; paint: mapboxgl.HeatmapLayerSpecification['paint'] }): void {\n this.map.addLayer({\n id: config.id,\n type: 'heatmap',\n source: config.source,\n maxzoom: config.maxzoom,\n paint: config.paint,\n });\n }\n\n /**\n * Apply a Mapbox filter expression to a layer, or pass `null` to clear it.\n * Silently no-ops if the layer doesn't exist.\n */\n public setFilter(layerId: string, filter: unknown[] | null): void {\n if (this.map.getLayer(layerId)) {\n this.map.setFilter(layerId, filter as mapboxgl.FilterSpecification | null);\n }\n }\n\n /**\n * Change a paint property on any layer (color, opacity, width, etc.).\n * Works on layers from the base style as well as layers you've added.\n * Silently no-ops when the layer is missing so style swaps don't throw.\n *\n * @example\n * map.setPaintProperty('road-primary', 'line-color', '#ff0080');\n * map.setPaintProperty('water', 'fill-opacity', 0.6);\n */\n public setPaintProperty(layerId: string, name: string, value: unknown): void {\n if (this.map.getLayer(layerId)) {\n (this.map.setPaintProperty as (id: string, name: string, value: unknown) => void)(\n layerId,\n name,\n value,\n );\n }\n }\n\n /**\n * Change a layout property on any layer (visibility, icon-image, text-field, etc.).\n *\n * @example\n * map.setLayoutProperty('poi-label', 'visibility', 'none');\n * map.setLayoutProperty('road-label', 'text-size', 14);\n */\n public setLayoutProperty(layerId: string, name: string, value: unknown): void {\n if (this.map.getLayer(layerId)) {\n (this.map.setLayoutProperty as (id: string, name: string, value: unknown) => void)(\n layerId,\n name,\n value,\n );\n }\n }\n\n /**\n * Return every layer id currently in the style.\n * Useful for discovering layer names from a custom Studio style so you can target them at runtime.\n */\n public getLayerIds(): string[] {\n return this.map.getStyle().layers.map((l) => l.id);\n }\n\n /** Move a layer to the top, or just under `beforeId`. No-op when the layer is missing. */\n public moveLayer(id: string, beforeId?: string): void {\n if (this.hasLayer(id)) {\n this.map.moveLayer(id, beforeId);\n }\n }\n\n /** `true` when a layer with this id exists in the current style. */\n public hasLayer(id: string): boolean {\n return !!this.map.getLayer(id);\n }\n\n /** `true` when a source with this id exists. */\n public hasSource(id: string): boolean {\n return !!this.map.getSource(id);\n }\n\n /** Remove a layer if present. Useful during style swaps or layer teardown. */\n public safeRemoveLayer(id: string): void {\n if (this.hasLayer(id)) {\n this.map.removeLayer(id);\n }\n }\n\n /** Convert geographic coordinates into pixel coordinates within the map container. */\n public project(lngLat: mapboxgl.LngLatLike): mapboxgl.Point {\n return this.map.project(lngLat);\n }\n\n /**\n * Register an image for use with `icon-image` in symbol layers. Accepts\n * either a pre-loaded `HTMLImageElement` or a URL to fetch. Updates an\n * existing entry when the id is already registered.\n */\n public async addImage(id: string, img: HTMLImageElement | string): Promise<void> {\n const imgEl = typeof img === 'string' ? await this.loadImage(img) : img;\n\n if (!this.map.hasImage(id)) {\n this.map.addImage(id, imgEl, { sdf: false });\n\n return;\n }\n\n this.map.updateImage(id, imgEl);\n }\n\n /**\n * Register `image` under `id`, replacing any image already there. Unlike `addImage`'s in-place update, the size and\n * the options (`pixelRatio`, `stretchX` / `stretchY`, `content`) may change, as a re-baked canvas sprite needs.\n */\n public replaceImage(id: string, image: MapImageSource, options?: MapImageOptions): void {\n if (this.map.hasImage(id)) {\n this.map.removeImage(id);\n }\n\n this.map.addImage(id, image, options);\n }\n\n /** Flip a layer's `visibility` between `'visible'` and `'none'`. */\n public toggleLayerVisibility(layerId: string): void {\n const vis = this.map.getLayoutProperty(layerId, 'visibility');\n\n this.map.setLayoutProperty(\n layerId,\n 'visibility',\n vis === 'visible' ? 'none' : 'visible',\n );\n }\n\n /**\n * Subscribe to a raw Mapbox event. Supports both the two-arg form\n * (`on(event, handler)`) and the layer-scoped form (`on(event, layerId, handler)`).\n */\n public on(event: string, ...args: unknown[]): void {\n (this.map as unknown as { on: (e: string, ...a: unknown[]) => void }).on(event, ...args);\n }\n\n /** Remove an event listener previously registered with `on`. */\n public off(event: string, ...args: unknown[]): void {\n (this.map as unknown as { off: (e: string, ...a: unknown[]) => void }).off(event, ...args);\n }\n\n /** Remove a source from the style. Remove any layers using it first. */\n public removeSource(id: string): void {\n this.map.removeSource(id);\n }\n\n /** Set arbitrary feature-state for a feature in a GeoJSON source. */\n public setFeatureState(\n sourceId: string,\n featureId: number | string,\n state: Record<string, unknown>,\n ): void {\n if (!this.map.getSource(sourceId)) {\n return;\n }\n\n this.map.setFeatureState({ source: sourceId, id: featureId }, state);\n }\n\n /** Remove a specific feature-state key, or all state for the feature when `key` is omitted. */\n public clearFeatureState(sourceId: string, featureId: number | string, key?: string): void {\n if (!this.map.getSource(sourceId)) {\n return;\n }\n\n if (!key) {\n this.map.removeFeatureState({ source: sourceId, id: featureId });\n\n return;\n }\n\n this.map.setFeatureState({ source: sourceId, id: featureId }, { [key]: false });\n }\n\n /**\n * Enter polygon-drawing mode. Lazily mounts a `@mapbox/mapbox-gl-draw` control,\n * hides its default UI (consumer controls the toggle), and switches to `draw_polygon`.\n * The user clicks vertices and double-clicks (or clicks the first vertex) to close.\n * The completed polygon is emitted on `polygonCreate`. `keepPanZoom` leaves drag and zoom on.\n */\n public enableDrawPolygon(options?: MapDrawOptions): void {\n if (!this.draw) {\n this.draw = new MapboxDraw({\n displayControlsDefault: false,\n controls: {},\n });\n\n this.map.addControl(this.draw);\n }\n\n if (!this.onDrawCreate) {\n this.onDrawCreate = (e) => {\n const polygon = e.features.find(\n (f) => f.geometry.type === 'Polygon',\n ) as GeoJSON.Feature<GeoJSON.Polygon> | undefined;\n\n if (polygon) {\n this.polygonCreate.next(polygon);\n }\n };\n\n (this.map as unknown as { on: (e: string, h: unknown) => void }).on(\n 'draw.create',\n this.onDrawCreate,\n );\n }\n\n this.lockInteractions(options?.keepPanZoom === true);\n\n this.draw.changeMode('draw_polygon');\n }\n\n /**\n * Close the polygon being drawn, as a double-click would: it is emitted on `polygonCreate` when it has three corners\n * or more. Draw mode (and its gesture lock) stays until `disableDrawPolygon`. No-op when not drawing.\n */\n public finishDrawPolygon(): void {\n this.draw?.changeMode('simple_select');\n }\n\n /** Exit polygon-drawing mode and remove any in-progress or drawn polygons. */\n public disableDrawPolygon(): void {\n if (this.onDrawCreate) {\n (this.map as unknown as { off: (e: string, h: unknown) => void }).off(\n 'draw.create',\n this.onDrawCreate,\n );\n this.onDrawCreate = undefined;\n }\n\n if (this.draw) {\n this.draw.deleteAll();\n this.map.removeControl(this.draw);\n this.draw = undefined;\n }\n\n this.unlockInteractions();\n }\n\n /**\n * Disable pan/zoom handlers so the viewport stays fixed while the user draws (drag, wheel and pinch stay on with\n * `keepPanZoom`). Saves the prior enabled-state for each handler so it can be restored by\n * `unlockInteractions`. Safe to call repeatedly — a second call is a no-op\n * because saved state is only captured on the first lock.\n */\n private lockInteractions(keepPanZoom: boolean): void {\n if (this.savedInteractions) {\n return;\n }\n\n this.savedInteractions = {\n dragPan: this.map.dragPan.isEnabled(),\n scrollZoom: this.map.scrollZoom.isEnabled(),\n boxZoom: this.map.boxZoom.isEnabled(),\n doubleClickZoom: this.map.doubleClickZoom.isEnabled(),\n touchZoomRotate: this.map.touchZoomRotate.isEnabled(),\n keyboard: this.map.keyboard.isEnabled(),\n };\n\n if (!keepPanZoom) {\n this.map.dragPan.disable();\n this.map.scrollZoom.disable();\n this.map.touchZoomRotate.disable();\n }\n\n this.map.boxZoom.disable();\n this.map.doubleClickZoom.disable();\n this.map.keyboard.disable();\n }\n\n /**\n * Restore every pan/zoom handler to the enabled-state captured by\n * `lockInteractions`. No-op when interactions were never locked.\n */\n private unlockInteractions(): void {\n if (!this.savedInteractions) {\n return;\n }\n\n const prev = this.savedInteractions;\n\n if (prev.dragPan) this.map.dragPan.enable();\n if (prev.scrollZoom) this.map.scrollZoom.enable();\n if (prev.boxZoom) this.map.boxZoom.enable();\n if (prev.doubleClickZoom) this.map.doubleClickZoom.enable();\n if (prev.touchZoomRotate) this.map.touchZoomRotate.enable();\n if (prev.keyboard) this.map.keyboard.enable();\n\n this.savedInteractions = undefined;\n }\n\n /** Remove every polygon the user has drawn, keeping draw mode active. */\n public clearDrawnPolygons(): void {\n this.draw?.deleteAll();\n }\n\n\n // The GeoJSON source under `sourceId` (it has the cluster calls), or null when it is missing or another kind.\n private clusterSourceOf(sourceId: string): mapboxgl.GeoJSONSource | null {\n const source = this.map.getSource(sourceId) as { getClusterLeaves?: unknown } | undefined;\n\n return source && typeof source.getClusterLeaves === 'function' ? source as unknown as mapboxgl.GeoJSONSource : null;\n }\n\n private notClusteredError(sourceId: string): Error {\n return new Error(`Source '${sourceId}' is not a clustered GeoJSON source or is missing.`);\n }\n\n private insetOf(insets: MapInsets, side: keyof PaddingOptions): number {\n return typeof insets === 'number' ? insets : insets[side] ?? 0;\n }\n\n /** `isStyleLoaded()` also waits for tiles; what addSource needs is mapbox's one-shot \"style parsed\" flag. */\n private isStyleParsed(): boolean {\n return this.map.isStyleLoaded() || !!(this.map as unknown as { style?: { _loaded?: boolean } }).style?._loaded;\n }\n\n /** Fetch a URL into an `HTMLImageElement`. Resolves on `load`, rejects on `error`. */\n private loadImage(url: string): Promise<HTMLImageElement> {\n return new Promise((res, rej) => {\n const img = new Image();\n\n img.onload = () => res(img);\n img.onerror = rej;\n img.src = url;\n });\n }\n\n}\n","import { isPlatformBrowser } from '@angular/common';\nimport {\n ChangeDetectionStrategy,\n Component,\n DestroyRef,\n ElementRef,\n PLATFORM_ID,\n ViewEncapsulation,\n effect,\n inject,\n input,\n output,\n viewChild,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\n\nimport type mapboxgl from 'mapbox-gl';\nimport type { StyleSpecification } from 'mapbox-gl';\n\nimport { MapboxService } from '../mapbox.service';\n\n/**\n * Thin host component that mounts a Mapbox map into a container div, forwards\n * lifecycle/events from `MapboxService`, and cleans up on destroy.\n *\n * Consumers interact with the underlying map via the public `map` (MapboxService)\n * instance — use `viewChild(ApexMapComponent)` in a parent to reach `component.map`\n * and call `addSource()`, `addLayer()`, `moveCenter()`, etc.\n *\n * Example:\n * <apex-map [center]=\"[-80.84, 35.22]\" [zoom]=\"11\" (mapReady)=\"onReady()\"/>\n */\n\n@Component({\n selector: 'apex-map',\n standalone: true,\n templateUrl: './apex-map.component.html',\n styleUrls: ['./apex-map.component.css'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n})\n\nexport class ApexMapComponent {\n\n public center = input<[number, number]>([-80.8431, 35.2271]);\n public zoom = input<number>(10);\n public mapStyle = input<string | StyleSpecification | undefined>(undefined);\n public maxBounds = input<mapboxgl.LngLatBoundsLike | undefined>(undefined);\n public showNavigation = input<boolean>(true);\n\n public mapReady = output<void>();\n public mapClick = output<mapboxgl.MapMouseEvent>();\n public featureClick = output<mapboxgl.MapMouseEvent>();\n\n readonly map = inject(MapboxService);\n\n private readonly platformId = inject(PLATFORM_ID);\n private readonly destroyRef = inject(DestroyRef);\n private readonly container = viewChild.required<ElementRef<HTMLElement>>('container');\n\n /**\n * Wire a reactive effect that emits `mapReady` once the underlying Mapbox\n * `load` event fires and `MapboxService.ready()` flips to `true`.\n */\n constructor() {\n effect(() => {\n if (this.map.ready()) {\n this.mapReady.emit();\n }\n });\n }\n\n /**\n * Initialise the Mapbox instance into the `#container` div, forward\n * `mapClick`/`featureClick` streams as component outputs, and register\n * teardown so the map is destroyed with the component.\n * No-op on non-browser platforms (SSR).\n */\n public ngAfterViewInit(): void {\n if (!isPlatformBrowser(this.platformId)) {\n return;\n }\n\n this.map.init({\n container: this.container().nativeElement,\n center: this.center(),\n zoom: this.zoom(),\n mapStyle: this.mapStyle(),\n maxBounds: this.maxBounds(),\n showNavigation: this.showNavigation(),\n });\n\n this.map.mapClick\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe((e) => this.mapClick.emit(e));\n\n this.map.featureClick\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe((e) => this.featureClick.emit(e));\n\n this.destroyRef.onDestroy(() => this.map.deactivate(this.container().nativeElement));\n }\n\n}\n","<div #container class=\"apex-map__container\"></div>\n","import { Directive, ElementRef, OnDestroy, inject } from '@angular/core';\n\nimport { MapboxService } from './mapbox.service';\n\n/**\n * A trackpad pinch arrives as a ctrl+wheel. Over anything laid on the map (a card, the map's buttons, a legend, a top\n * bar) it would zoom the page; this hands it to the shared map under it instead. Put it on the overlay itself, or on a\n * container holding the map and its overlays.\n */\n@Directive({\n selector: '[apexMapPinchZoom]',\n standalone: true,\n})\nexport class ApexMapPinchZoomDirective implements OnDestroy {\n\n constructor() {\n // Not passive, so the pinch can stop the page from zooming.\n this.host.nativeElement.addEventListener('wheel', this.onWheel, { passive: false });\n }\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly map = inject(MapboxService);\n\n /** Stops listening. */\n public ngOnDestroy(): void {\n this.host.nativeElement.removeEventListener('wheel', this.onWheel);\n }\n\n private readonly onWheel = (event: WheelEvent): void => {\n // Taken already (mapbox over its own canvas, an overlay nested in this one), or our own re-dispatch (untrusted).\n if (!event.ctrlKey || !event.isTrusted || event.defaultPrevented || !this.holdsShownMap()) {\n return;\n }\n\n const rawMap = this.map.getMap();\n\n if (!rawMap?.scrollZoom.isEnabled()) {\n return;\n }\n\n // Only over the map itself, measured on its container: the canvas container mapbox listens on has no height.\n const rect = rawMap.getContainer().getBoundingClientRect();\n\n if (event.clientX < rect.left || event.clientX > rect.right || event.clientY < rect.top || event.clientY > rect.bottom) {\n return;\n }\n\n event.preventDefault();\n\n rawMap.getCanvasContainer().dispatchEvent(new WheelEvent('wheel', {\n bubbles: true,\n cancelable: true,\n ctrlKey: true,\n shiftKey: event.shiftKey,\n clientX: event.clientX,\n clientY: event.clientY,\n deltaX: event.deltaX,\n deltaY: event.deltaY,\n deltaMode: event.deltaMode,\n }));\n };\n\n // The one map moves between surfaces: zoom it only while it is shown inside this element (a container) or inside the\n // element this one is positioned in (a card anchored over the map).\n private holdsShownMap(): boolean {\n const host = this.host.nativeElement;\n const anchor = host.offsetParent;\n\n return this.map.isShownIn(host) || (anchor !== null && this.map.isShownIn(anchor));\n }\n\n}\n","import { signal } from '@angular/core';\n\nimport { MapGeolocationUtil, type MapLngLat, type MapLocateOptions, type MapLocateResult } from '@apexara/map/geo';\n\nimport type * as GeoJSON from 'geojson';\n\nimport type { MapboxService } from './mapbox.service';\nimport { MapUserLocationConfig, MapUserLocationStyle } from './map.types';\n\n/**\n * The reader's location as a dot on the map, in the consumer's `style`, and the camera move to it at the consumer's\n * `zoom`. Not injectable: a map surface builds one with the `MapboxService` it draws on, repaints it after a style swap\n * and destroys it on teardown.\n */\nexport class MapUserLocationLayer {\n\n constructor(\n private readonly map: MapboxService,\n config: MapUserLocationConfig) {\n this.sourceId = config.sourceId ?? 'user-location';\n this.layerId = config.layerId ?? 'user-location-dot';\n this.zoom = config.zoom;\n this.style = { ...config.style };\n }\n\n /** The last location read, as `[lng, lat]`; null until one is. */\n public readonly location = signal<MapLngLat | null>(null);\n\n private readonly sourceId: string;\n private readonly layerId: string;\n private readonly zoom: number;\n private readonly style: MapUserLocationStyle;\n\n /** Reads the location once and draws the dot; the camera stays where it is. */\n public async init(options?: MapLocateOptions): Promise<MapLocateResult> {\n const result = await MapGeolocationUtil.locate(options);\n\n if (result.status === 'located') {\n this.location.set(result.position);\n this.repaint();\n }\n\n return result;\n }\n\n /** Flies to the location (at the configured zoom), reading it first when none is known yet. */\n public async locate(options?: MapLocateOptions): Promise<MapLocateResult> {\n const known = this.location();\n\n if (known) {\n this.map.moveCenter(known, this.zoom);\n\n return { status: 'located', position: known };\n }\n\n const result = await this.init(options);\n\n if (result.status === 'located') {\n this.map.moveCenter(result.position, this.zoom);\n }\n\n return result;\n }\n\n /** Puts the dot (back) on the map, e.g. after a style swap. No-op until a location is known. */\n public repaint(): void {\n const position = this.location();\n\n if (!position) {\n return;\n }\n\n this.map.upsertSource({ id: this.sourceId, data: this.pointOf(position) });\n\n if (this.map.hasLayer(this.layerId)) {\n return;\n }\n\n this.map.addLayer({\n id: this.layerId,\n type: 'circle',\n source: this.sourceId,\n paint: {\n 'circle-radius': this.style.circleRadius,\n 'circle-color': this.style.circleColor,\n 'circle-stroke-color': this.style.strokeColor,\n 'circle-stroke-width': this.style.strokeWidth,\n },\n });\n }\n\n /** Takes the dot off the map; the location is kept for the next `repaint`. */\n public destroy(): void {\n this.map.safeRemoveLayer(this.layerId);\n\n if (this.map.hasSource(this.sourceId)) {\n this.map.removeSource(this.sourceId);\n }\n }\n\n private pointOf(position: MapLngLat): GeoJSON.FeatureCollection<GeoJSON.Point> {\n return {\n type: 'FeatureCollection',\n features: [{ type: 'Feature', geometry: { type: 'Point', coordinates: position }, properties: {} }],\n };\n }\n\n}\n","import type mapboxgl from 'mapbox-gl';\nimport type { Position } from 'geojson';\n\nimport { MapGeometryUtil, type MapBoundsOptions } from '@apexara/map/geo';\n\ntype Coord = [number, number];\n\n/**\n * Recursively flatten any nesting of GeoJSON coordinates down to a flat list of [lng, lat] pairs.\n * Handles Point, LineString, Polygon, and MultiPolygon coordinate shapes uniformly.\n */\nexport function flattenCoords(arr: Position | Position[] | Position[][] | Position[][][]): Coord[] {\n const out: Coord[] = [];\n\n MapGeometryUtil.forEachPosition(arr, (position) => out.push(position as Coord));\n\n return out;\n}\n\n/**\n * Compute the [[minLng, minLat], [maxLng, maxLat]] bounds of a flat list of coordinates, compatible with\n * `mapboxgl.LngLatBoundsLike`. `wrapAntimeridian` frames a shape across ±180° by its narrower side. No coordinates give\n * `[[180, 90], [-180, -90]]`. For whole GeoJSON, `MapGeometryUtil.boundsOf` walks it without flattening.\n */\nexport function calculateBounds(coords: Coord[], options?: MapBoundsOptions): mapboxgl.LngLatBoundsLike {\n return MapGeometryUtil.boundsOf({ type: 'MultiPoint', coordinates: coords }, options) ?? [[180, 90], [-180, -90]];\n}\n\n/**\n * Build a closed square polygon of side `2 * radiusKm` centered at `center`.\n * Useful when you need a small viewport-like polygon for point-in-polygon queries.\n */\nexport function calculateViewportPolygonFromCenter(center: Coord, radiusKm = 0.5): number[][][] {\n const [lng, lat] = center;\n\n const degreesPerMeterLng = 1 / (111320 * Math.cos((lat * Math.PI) / 180));\n const degreesPerMeterLat = 1 / 110540;\n\n const radiusMeters = radiusKm * 1000;\n const lngDelta = radiusMeters * degreesPerMeterLng;\n const latDelta = radiusMeters * degreesPerMeterLat;\n\n return [\n [\n [lng - lngDelta, lat - latDelta],\n [lng + lngDelta, lat - latDelta],\n [lng + lngDelta, lat + latDelta],\n [lng - lngDelta, lat + latDelta],\n [lng - lngDelta, lat - latDelta],\n ],\n ];\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;AA2BA;;;;;;;;;;;;AAYG;AAEH;AACA;AACA;AACA,MAAM,UAAU,GAAG,IAAI,GAAG,EAAuC;MAGpD,aAAa,CAAA;AAD1B,IAAA,WAAA,GAAA;;AAIS,QAAA,IAAA,CAAA,QAAQ,GAAG,IAAI,OAAO,EAA0B;;AAGhD,QAAA,IAAA,CAAA,YAAY,GAAG,IAAI,OAAO,EAA0B;;AAGpD,QAAA,IAAA,CAAA,aAAa,GAAG,IAAI,OAAO,EAAoC;AAErD,QAAA,IAAA,CAAA,MAAM,GAAG,MAAM,CAAU,KAAK,kDAAC;;AAGhC,QAAA,IAAA,CAAA,KAAK,GAAoB,IAAI,CAAC,MAAM;;AAGpC,QAAA,IAAA,CAAA,MAAM,GAAG,MAAM,CAA0B,IAAI,kDAAC;;AAG9C,QAAA,IAAA,CAAA,IAAI,GAAG,MAAM,CAAgB,IAAI,gDAAC;;AAGlC,QAAA,IAAA,CAAA,MAAM,GAAG,MAAM,CAA8C,IAAI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1.3.0",
4
4
  "private": false,
5
5
  "peerDependencies": {
6
6
  "@angular/common": ">=21.2.0",
@@ -30,6 +30,9 @@
30
30
  "module": "fesm2022/apexara-map.mjs",
31
31
  "typings": "types/apexara-map.d.ts",
32
32
  "sideEffects": false,
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
33
36
  "exports": {
34
37
  "./package.json": {
35
38
  "default": "./package.json"
@@ -41,6 +44,15 @@
41
44
  "./config": {
42
45
  "types": "./types/apexara-map-config.d.ts",
43
46
  "default": "./fesm2022/apexara-map-config.mjs"
47
+ },
48
+ "./geo": {
49
+ "types": "./types/apexara-map-geo.d.ts",
50
+ "default": "./fesm2022/apexara-map-geo.mjs"
51
+ },
52
+ "./search": {
53
+ "types": "./types/apexara-map-search.d.ts",
54
+ "default": "./fesm2022/apexara-map-search.mjs"
44
55
  }
45
- }
56
+ },
57
+ "gitHead": "7991b10400fc8a2215a08618bfa8325a6ade565a"
46
58
  }
@@ -0,0 +1,217 @@
1
+ import * as GeoJSON from 'geojson';
2
+
3
+ /** Every Mapbox web address the package calls or builds. */
4
+ declare class MapApiConfig {
5
+ /** Search Box API: `/suggest` and `/retrieve/<mapbox_id>`. */
6
+ static readonly SEARCH_BOX_URL = "https://api.mapbox.com/search/searchbox/v1";
7
+ /** Styles API: `/<owner>/<id>/static/...` serves a style as a still image. */
8
+ static readonly STYLES_URL = "https://api.mapbox.com/styles/v1";
9
+ /** What a hosted style URL starts with, as in `MapStyles`. */
10
+ static readonly STYLE_URL_PREFIX = "mapbox://styles/";
11
+ }
12
+
13
+ /** CSS colours in the form mapbox's style parser accepts, e.g. for a paint value read from a CSS custom property. */
14
+ declare class MapColorUtil {
15
+ private static readonly HASH_CODE;
16
+ /** `#rrggbbaa` and `#rgba`, which mapbox rejects, as `rgba(r, g, b, a)` with the alpha to three places; else as it is. */
17
+ static toMapboxColor(cssColor: string): string;
18
+ private static rgbaOf;
19
+ private static isHexAfterHash;
20
+ private static isHexDigit;
21
+ }
22
+
23
+ /** A `[lng, lat]` pair: the order GeoJSON and mapbox use. */
24
+ type MapLngLat = [number, number];
25
+ /** `[[west, south], [east, north]]`, which mapbox takes as `LngLatBoundsLike`. */
26
+ type MapBounds = [MapLngLat, MapLngLat];
27
+ /** GeoJSON coordinates at any nesting: a position, a line or ring, a polygon, a multipolygon. */
28
+ type MapCoordinates = GeoJSON.Position | GeoJSON.Position[] | GeoJSON.Position[][] | GeoJSON.Position[][][];
29
+ interface MapBoundsOptions {
30
+ /**
31
+ * Also measure longitudes on 0–360 and keep the narrower span, for a shape across ±180° (the Aleutians, Fiji). East
32
+ * may then pass 180, which mapbox wraps itself.
33
+ */
34
+ wrapAntimeridian?: boolean;
35
+ }
36
+ /** A frame in pixels. A `DOMRect` is one. */
37
+ interface MapSize {
38
+ width: number;
39
+ height: number;
40
+ }
41
+ /** A centre and a zoom, as `MapInitOptions` and `jumpTo` take them. */
42
+ interface MapCamera {
43
+ center: MapLngLat;
44
+ zoom: number;
45
+ }
46
+ /** `located`, the reader refused (`denied`), or no answer: no geolocation, a timeout, an error (`unavailable`). */
47
+ type MapLocateStatus = 'located' | 'denied' | 'unavailable';
48
+ /** What one read of the browser's location ended in. */
49
+ type MapLocateResult = {
50
+ status: 'located';
51
+ position: MapLngLat;
52
+ } | {
53
+ status: Exclude<MapLocateStatus, 'located'>;
54
+ };
55
+ /** The browser's own `PositionOptions`. */
56
+ interface MapLocateOptions {
57
+ /** A fix this many milliseconds old still answers, without waiting on the device. */
58
+ maximumAge?: number;
59
+ /** Milliseconds before the read gives up as `unavailable`. */
60
+ timeout?: number;
61
+ enableHighAccuracy?: boolean;
62
+ }
63
+ interface MapStaticImageOptions {
64
+ /** Mapbox public access token (pk.*). */
65
+ accessToken: string;
66
+ /** A hosted style: `mapbox://styles/<owner>/<id>` (a `MapStyles` value) or `<owner>/<id>`. */
67
+ style: string;
68
+ center: MapLngLat;
69
+ zoom: number;
70
+ /** Degrees; mapbox's default is 0. */
71
+ bearing?: number;
72
+ /** Degrees; mapbox's default is 0. */
73
+ pitch?: number;
74
+ /** Pixels, at most 1280. */
75
+ width: number;
76
+ /** Pixels, at most 1280. */
77
+ height: number;
78
+ /** Twice the pixels, for a high-density screen. */
79
+ retina?: boolean;
80
+ /** Mapbox's default is true. */
81
+ attribution?: boolean;
82
+ /** Mapbox's default is true. */
83
+ logo?: boolean;
84
+ }
85
+ /** One level of a result's `context`: `place` (city), `region`, `postcode`, `address`. */
86
+ interface MapSearchApiContextEntry {
87
+ name?: string;
88
+ /** The region's short code, e.g. `NC`. */
89
+ region_code?: string;
90
+ }
91
+ /** Where a result sits. Search Box and Geocoding v6 share this shape. */
92
+ interface MapSearchApiContext {
93
+ place?: MapSearchApiContextEntry;
94
+ region?: MapSearchApiContextEntry;
95
+ postcode?: MapSearchApiContextEntry;
96
+ address?: MapSearchApiContextEntry;
97
+ }
98
+ /** The naming fields a suggestion and a retrieved feature's properties share. */
99
+ interface MapSearchApiNamed {
100
+ name?: string;
101
+ full_address?: string;
102
+ place_formatted?: string;
103
+ context?: MapSearchApiContext;
104
+ }
105
+ interface MapSearchApiSuggestion extends MapSearchApiNamed {
106
+ mapbox_id?: string;
107
+ }
108
+ interface MapSearchApiFeature {
109
+ geometry?: {
110
+ coordinates?: number[];
111
+ };
112
+ properties?: MapSearchApiNamed;
113
+ }
114
+ interface MapSearchApiSuggestResponse {
115
+ suggestions?: MapSearchApiSuggestion[];
116
+ }
117
+ interface MapSearchApiRetrieveResponse {
118
+ features?: MapSearchApiFeature[];
119
+ }
120
+ /** City, region code and postcode, under Mapbox's own names; an empty string for what Mapbox did not send. */
121
+ interface MapSearchLocality {
122
+ city: string;
123
+ /** Mapbox's `region_code`, e.g. `NC`. */
124
+ region: string;
125
+ /** Mapbox's `postcode`, e.g. `28202`. */
126
+ postcode: string;
127
+ }
128
+ /** A search result: a suggestion (no position yet) or a retrieved place. */
129
+ interface MapSearchResult extends MapSearchLocality {
130
+ mapboxId: string;
131
+ /** The result's own name; for an address, the street line. */
132
+ name: string;
133
+ /** The whole formatted line, for a dropdown row. */
134
+ fullAddress: string;
135
+ /** Null on a suggestion: only `retrieve` returns a position. */
136
+ lat: number | null;
137
+ lon: number | null;
138
+ }
139
+
140
+ /** One read of the browser's location, as a promise that always resolves. */
141
+ declare class MapGeolocationUtil {
142
+ /** The reader's position as `[lng, lat]`, or why there is none. `unavailable` at once where there is no geolocation. */
143
+ static locate(options?: MapLocateOptions): Promise<MapLocateResult>;
144
+ }
145
+
146
+ /** Plain geometry for maps: distances, boxes, circles, bounds and the camera framing them. Every point is `[lng, lat]`. */
147
+ declare class MapGeometryUtil {
148
+ /** Metres in a statute mile. */
149
+ static readonly METRES_PER_MILE = 1609.344;
150
+ /** Mapbox's deepest zoom: where `cameraForBounds` holds a box with no area. */
151
+ static readonly MAX_ZOOM = 22;
152
+ private static readonly EARTH_RADIUS_MILES;
153
+ private static readonly METRES_PER_DEGREE;
154
+ private static readonly MIN_LATITUDE_COSINE;
155
+ private static readonly WORLD_WIDTH_AT_ZOOM_ZERO_PX;
156
+ private static readonly CIRCLE_SEGMENTS;
157
+ /** Great-circle (haversine) miles between two points, rounded to `decimals` when given. */
158
+ static milesBetween(from: MapLngLat, to: MapLngLat, decimals?: number): number;
159
+ /** Whether a point can go on a map: both finite, and not the 0, 0 a record with no location tends to arrive as. */
160
+ static hasLocation(lng: number | null | undefined, lat: number | null | undefined): boolean;
161
+ /** The bounds of a square reaching `metres` from `center` on every side, e.g. to frame a circle of that radius. */
162
+ static boundsAround(center: MapLngLat, metres: number): MapBounds;
163
+ /** The closed ring (last point equals the first) of a ground circle `metres` in radius, for a GeoJSON polygon. */
164
+ static circleRing(center: MapLngLat, metres: number, segments?: number): MapLngLat[];
165
+ /**
166
+ * The Web Mercator centre and zoom fitting `bounds` in a `size` frame with `padding` on every side, before any map
167
+ * exists (mapbox's own `cameraForBounds` needs one). Null when the padding leaves no room. Zoom is capped at `maxZoom`.
168
+ */
169
+ static cameraForBounds(bounds: MapBounds, size: MapSize, padding?: number, maxZoom?: number): MapCamera | null;
170
+ /**
171
+ * The bounds of every position in any GeoJSON (collection, feature, geometry), walked in place: no flat copy, so a
172
+ * state's hundreds of thousands of points cost no allocation. Null when it holds no position.
173
+ */
174
+ static boundsOf(geoJson: GeoJSON.GeoJSON, options?: MapBoundsOptions): MapBounds | null;
175
+ /**
176
+ * Whether `outer` covers all of `inner`, edges included. `tolerance` forgives a miss up to that share of `inner`'s span
177
+ * per axis, e.g. 0.001 where `outer` was framed to `inner`'s edge and rounding can leave it a hair short.
178
+ */
179
+ static containsBounds(outer: MapBounds, inner: MapBounds, tolerance?: number): boolean;
180
+ /**
181
+ * Whether two polygons' outer rings match point for point (holes are not compared), e.g. as the `equal` of a signal
182
+ * holding `getViewportPolygon()`, so an unmoved camera is no change.
183
+ */
184
+ static sameOuterRing(first: GeoJSON.Position[][] | null, second: GeoJSON.Position[][] | null): boolean;
185
+ /** Calls `visit` with every position in GeoJSON coordinates at any nesting, in order, as the arrays they are. */
186
+ static forEachPosition(coordinates: MapCoordinates, visit: (position: GeoJSON.Position) => void): void;
187
+ private static extendByGeoJson;
188
+ private static extend;
189
+ private static boundsOfExtent;
190
+ private static lngDeltaAt;
191
+ private static mercatorY;
192
+ private static toRadians;
193
+ }
194
+
195
+ /** Reads Mapbox Search responses into results. `localityOf` also reads a Geocoding v6 feature's context. */
196
+ declare class MapSearchResponseUtil {
197
+ /** City, region code and postcode from a result's `context`; an empty string for what it lacks. */
198
+ static localityOf(context: MapSearchApiContext | undefined): MapSearchLocality;
199
+ /** A `suggest` item as a result, with no position: `retrieve` gives that. */
200
+ static resultOf(suggestion: MapSearchApiSuggestion): MapSearchResult;
201
+ /** A `retrieve` feature as a result, with its position. */
202
+ static placeOf(mapboxId: string, feature: MapSearchApiFeature): MapSearchResult;
203
+ private static namesOf;
204
+ private static joinedAddress;
205
+ }
206
+
207
+ /** Mapbox Static Images: a style rendered as one still, e.g. a placeholder while the live map is held back. */
208
+ declare class MapStaticImageUtil {
209
+ /** The image's URL. Options left out take mapbox's defaults (bearing and pitch 0, attribution and logo shown). */
210
+ static url(options: MapStaticImageOptions): string;
211
+ private static stylePathOf;
212
+ private static cameraOf;
213
+ private static queryOf;
214
+ }
215
+
216
+ export { MapApiConfig, MapColorUtil, MapGeolocationUtil, MapGeometryUtil, MapSearchResponseUtil, MapStaticImageUtil };
217
+ export type { MapBounds, MapBoundsOptions, MapCamera, MapCoordinates, MapLngLat, MapLocateOptions, MapLocateResult, MapLocateStatus, MapSearchApiContext, MapSearchApiContextEntry, MapSearchApiFeature, MapSearchApiNamed, MapSearchApiRetrieveResponse, MapSearchApiSuggestResponse, MapSearchApiSuggestion, MapSearchLocality, MapSearchResult, MapSize, MapStaticImageOptions };
@@ -0,0 +1,39 @@
1
+ import { MapSearchResult } from '@apexara/map/geo';
2
+ export { MapSearchResult } from '@apexara/map/geo';
3
+ import * as i0 from '@angular/core';
4
+
5
+ /** Filters for `MapboxSearchService.suggest`. Each left out takes Mapbox's default. */
6
+ interface MapSearchSuggestOptions {
7
+ /** Comma-separated feature types, e.g. `'address'` for street addresses only. */
8
+ types?: string;
9
+ /** Comma-separated ISO 3166 alpha-2 codes, e.g. `'us'`. */
10
+ country?: string;
11
+ /** How many suggestions, at most 10. */
12
+ limit?: number;
13
+ }
14
+
15
+ /**
16
+ * Mapbox Search Box: `suggest` while the reader types, `retrieve` on a pick, billed per session (the session token
17
+ * rotates after a retrieve). Quiet on failure ([] or null, 5 s timeout). Uses `fetch`, never HttpClient, whose
18
+ * interceptors could send an app's own credentials to api.mapbox.com.
19
+ */
20
+ declare class MapboxSearchService {
21
+ private readonly config;
22
+ private readonly platformId;
23
+ private readonly requestTimeoutMs;
24
+ private sessionToken;
25
+ /** Whether a search can run: a token is configured and this is a browser. */
26
+ get isAvailable(): boolean;
27
+ /** Suggestions for `query`, with no position yet. [] when unavailable or on any failure. */
28
+ suggest(query: string, options?: MapSearchSuggestOptions): Promise<MapSearchResult[]>;
29
+ /** A suggestion's full record, the only call with a position; it ends the session. Null when unavailable or none. */
30
+ retrieve(mapboxId: string): Promise<MapSearchResult | null>;
31
+ private suggestParams;
32
+ private session;
33
+ private get;
34
+ static ɵfac: i0.ɵɵFactoryDeclaration<MapboxSearchService, never>;
35
+ static ɵprov: i0.ɵɵInjectableDeclaration<MapboxSearchService>;
36
+ }
37
+
38
+ export { MapboxSearchService };
39
+ export type { MapSearchSuggestOptions };