@apexara/map 1.0.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/README.md +428 -0
- package/fesm2022/apexara-map.mjs +720 -0
- package/fesm2022/apexara-map.mjs.map +1 -0
- package/package.json +42 -0
- package/types/apexara-map.d.ts +307 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apexara-map.mjs","sources":["../../../../projects/apexara/map/src/lib/map.tokens.ts","../../../../projects/apexara/map/src/lib/map.types.ts","../../../../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 {\n EnvironmentProviders,\n InjectionToken,\n makeEnvironmentProviders,\n} from '@angular/core';\n\nimport type { StyleSpecification } from 'mapbox-gl';\n\nimport { MapStyles } from './map.types';\n\nexport interface MapConfig {\n /** Mapbox public access token (pk.*). Required. */\n accessToken: string;\n /**\n * Default style applied when a consumer doesn't pass `mapStyle` to init.\n * Accepts a style URL, a `MapStyles` enum value, or a full inline `StyleSpecification`.\n */\n defaultStyle?: MapStyles | string | StyleSpecification;\n}\n\nexport const MAP_CONFIG = new InjectionToken<MapConfig>('APEX_MAP_CONFIG');\n\n/**\n * Register @apexara/map at the application root.\n *\n * @example\n * // app.config.ts\n * providers: [\n * provideMap({ accessToken: environment.mapboxToken }),\n * ]\n */\nexport function provideMap(config: MapConfig): EnvironmentProviders {\n return makeEnvironmentProviders([{ provide: MAP_CONFIG, useValue: config }]);\n}\n","import type mapboxgl from 'mapbox-gl';\nimport type * as GeoJSON from 'geojson';\n\nexport interface MapInitOptions {\n /** DOM element the map renders into. */\n container: HTMLElement;\n /** Initial center as [lng, lat]. */\n center: [number, number];\n /** Initial zoom (defaults to 10). */\n zoom?: number;\n /** Constrain panning to these bounds. */\n maxBounds?: mapboxgl.LngLatBoundsLike;\n /**\n * Map style. Accepts:\n * - a Mapbox-hosted style URL (e.g. `'mapbox://styles/<user>/<id>'` or a `MapStyles` enum value),\n * - an HTTPS URL to a Mapbox-compatible style JSON, or\n * - a full inline `StyleSpecification` object.\n * Falls back to the configured default, then `MapStyles.Streets`.\n */\n mapStyle?: string | mapboxgl.StyleSpecification;\n /** Add the built-in NavigationControl. Defaults to true. */\n showNavigation?: boolean;\n}\n\nexport interface SourceConfig {\n id: string;\n data: string | GeoJSON.FeatureCollection;\n clustered?: boolean;\n clusterRadius?: number;\n clusterMaxZoom?: number;\n /** When true, Mapbox auto-generates a stable numeric `id` per feature — required for feature-state APIs. */\n generateId?: boolean;\n}\n\nexport enum MapStyles {\n Sat = 'mapbox://styles/mapbox/satellite-streets-v12',\n Streets = 'mapbox://styles/mapbox/streets-v12',\n DarkV11 = 'mapbox://styles/mapbox/dark-v11',\n LightV11 = 'mapbox://styles/mapbox/light-v11',\n OutdoorsV12 = 'mapbox://styles/mapbox/outdoors-v12',\n}\n","import { isPlatformBrowser } from '@angular/common';\nimport { 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 type * as GeoJSON from 'geojson';\nimport type { Position } from 'geojson';\n\nimport { MAP_CONFIG } from './map.tokens';\nimport { MapInitOptions, MapStyles, 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 /** 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 public activate(container: HTMLElement, options: MapInitOptions): void {\n if (!isPlatformBrowser(this.platformId)) {\n return;\n }\n\n if (!this.mapInitialised) {\n this.createMap(container, options);\n this.containerStack.push(container);\n this._activeContainer.set(container);\n return;\n }\n\n const active = this._activeContainer();\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 return;\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\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 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 /**\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 /** 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 /** 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';\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(\n arr: Coord | Coord[] | Coord[][] | Coord[][][],\n): 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":";;;;;;;;MAoBa,UAAU,GAAG,IAAI,cAAc,CAAY,iBAAiB;AAEzE;;;;;;;;AAQG;AACG,SAAU,UAAU,CAAC,MAAiB,EAAA;AAC1C,IAAA,OAAO,wBAAwB,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;AAC9E;;ICCY;AAAZ,CAAA,UAAY,SAAS,EAAA;AACnB,IAAA,SAAA,CAAA,KAAA,CAAA,GAAA,8CAAoD;AACpD,IAAA,SAAA,CAAA,SAAA,CAAA,GAAA,oCAA8C;AAC9C,IAAA,SAAA,CAAA,SAAA,CAAA,GAAA,iCAA2C;AAC3C,IAAA,SAAA,CAAA,UAAA,CAAA,GAAA,kCAA6C;AAC7C,IAAA,SAAA,CAAA,aAAA,CAAA,GAAA,qCAAmD;AACrD,CAAC,EANW,SAAS,KAAT,SAAS,GAAA,EAAA,CAAA,CAAA;;ACpBrB;;;;;;;;;;;;AAYG;AAEH;AACA;AACA;AACA,MAAM,UAAU,GAAG,IAAI,GAAG,EAAuC;MAGpD,aAAa,CAAA;A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9E,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;;AC5EA;;AAEG;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@apexara/map",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"peerDependencies": {
|
|
6
|
+
"@angular/common": ">=21.2.0",
|
|
7
|
+
"@angular/core": ">=21.2.0",
|
|
8
|
+
"@mapbox/mapbox-gl-draw": "^1.5.0",
|
|
9
|
+
"mapbox-gl": "^3.0.0",
|
|
10
|
+
"rxjs": "^7.8.0"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"tslib": "^2.8.0"
|
|
14
|
+
},
|
|
15
|
+
"author": "apexara",
|
|
16
|
+
"license": "ISC",
|
|
17
|
+
"description": "Reusable Mapbox GL wrapper for Apexara Angular apps",
|
|
18
|
+
"keywords": [
|
|
19
|
+
"Angular",
|
|
20
|
+
"Angular 19",
|
|
21
|
+
"Angular 20",
|
|
22
|
+
"Angular 21",
|
|
23
|
+
"Mapbox",
|
|
24
|
+
"Mapbox GL",
|
|
25
|
+
"Map",
|
|
26
|
+
"Apexara",
|
|
27
|
+
"ng map",
|
|
28
|
+
"ng mapbox"
|
|
29
|
+
],
|
|
30
|
+
"module": "fesm2022/apexara-map.mjs",
|
|
31
|
+
"typings": "types/apexara-map.d.ts",
|
|
32
|
+
"sideEffects": false,
|
|
33
|
+
"exports": {
|
|
34
|
+
"./package.json": {
|
|
35
|
+
"default": "./package.json"
|
|
36
|
+
},
|
|
37
|
+
".": {
|
|
38
|
+
"types": "./types/apexara-map.d.ts",
|
|
39
|
+
"default": "./fesm2022/apexara-map.mjs"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import * as mapbox_gl from 'mapbox-gl';
|
|
2
|
+
import { LayerSpecification, StyleSpecification } from 'mapbox-gl';
|
|
3
|
+
import * as _angular_core from '@angular/core';
|
|
4
|
+
import { Signal, WritableSignal, InjectionToken, EnvironmentProviders } from '@angular/core';
|
|
5
|
+
import { Subject } from 'rxjs';
|
|
6
|
+
import * as GeoJSON from 'geojson';
|
|
7
|
+
import { Position } from 'geojson';
|
|
8
|
+
|
|
9
|
+
interface MapInitOptions {
|
|
10
|
+
/** DOM element the map renders into. */
|
|
11
|
+
container: HTMLElement;
|
|
12
|
+
/** Initial center as [lng, lat]. */
|
|
13
|
+
center: [number, number];
|
|
14
|
+
/** Initial zoom (defaults to 10). */
|
|
15
|
+
zoom?: number;
|
|
16
|
+
/** Constrain panning to these bounds. */
|
|
17
|
+
maxBounds?: mapboxgl.LngLatBoundsLike;
|
|
18
|
+
/**
|
|
19
|
+
* Map style. Accepts:
|
|
20
|
+
* - a Mapbox-hosted style URL (e.g. `'mapbox://styles/<user>/<id>'` or a `MapStyles` enum value),
|
|
21
|
+
* - an HTTPS URL to a Mapbox-compatible style JSON, or
|
|
22
|
+
* - a full inline `StyleSpecification` object.
|
|
23
|
+
* Falls back to the configured default, then `MapStyles.Streets`.
|
|
24
|
+
*/
|
|
25
|
+
mapStyle?: string | mapboxgl.StyleSpecification;
|
|
26
|
+
/** Add the built-in NavigationControl. Defaults to true. */
|
|
27
|
+
showNavigation?: boolean;
|
|
28
|
+
}
|
|
29
|
+
interface SourceConfig {
|
|
30
|
+
id: string;
|
|
31
|
+
data: string | GeoJSON.FeatureCollection;
|
|
32
|
+
clustered?: boolean;
|
|
33
|
+
clusterRadius?: number;
|
|
34
|
+
clusterMaxZoom?: number;
|
|
35
|
+
/** When true, Mapbox auto-generates a stable numeric `id` per feature — required for feature-state APIs. */
|
|
36
|
+
generateId?: boolean;
|
|
37
|
+
}
|
|
38
|
+
declare enum MapStyles {
|
|
39
|
+
Sat = "mapbox://styles/mapbox/satellite-streets-v12",
|
|
40
|
+
Streets = "mapbox://styles/mapbox/streets-v12",
|
|
41
|
+
DarkV11 = "mapbox://styles/mapbox/dark-v11",
|
|
42
|
+
LightV11 = "mapbox://styles/mapbox/light-v11",
|
|
43
|
+
OutdoorsV12 = "mapbox://styles/mapbox/outdoors-v12"
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
declare class MapboxService {
|
|
47
|
+
/** Click on empty canvas (no features under the cursor). Event stream. */
|
|
48
|
+
mapClick: Subject<mapbox_gl.MapMouseEvent>;
|
|
49
|
+
/** Click on a feature (wired by consumers via `on('click', layerId, ...)`). Event stream. */
|
|
50
|
+
featureClick: Subject<mapbox_gl.MapMouseEvent>;
|
|
51
|
+
/** Fires when the user completes a polygon in draw mode (double-click or first-vertex click). */
|
|
52
|
+
polygonCreate: Subject<GeoJSON.Feature<GeoJSON.Polygon, GeoJSON.GeoJsonProperties>>;
|
|
53
|
+
private readonly _ready;
|
|
54
|
+
/** Reactive state: `true` once the map's `load` event has fired. */
|
|
55
|
+
readonly ready: Signal<boolean>;
|
|
56
|
+
/** Reactive state: current center `[lng, lat]`. Updates on `moveend`. `null` before init. */
|
|
57
|
+
readonly center: WritableSignal<[number, number] | null>;
|
|
58
|
+
/** Reactive state: current zoom level. Updates on `moveend`. `null` before init. */
|
|
59
|
+
readonly zoom: WritableSignal<number | null>;
|
|
60
|
+
/** Reactive state: current viewport bounds `[[swLng, swLat], [neLng, neLat]]`. Updates on `moveend`. */
|
|
61
|
+
readonly bounds: WritableSignal<[[number, number], [number, number]] | null>;
|
|
62
|
+
/** Reactive state: `true` while the map is panning/zooming (between `movestart` and `moveend`). */
|
|
63
|
+
readonly isMoving: WritableSignal<boolean>;
|
|
64
|
+
private map;
|
|
65
|
+
private mapInitialised;
|
|
66
|
+
private draw?;
|
|
67
|
+
private readonly config;
|
|
68
|
+
private readonly platformId;
|
|
69
|
+
private onDrawCreate?;
|
|
70
|
+
private savedInteractions?;
|
|
71
|
+
private hostDiv;
|
|
72
|
+
private containerStack;
|
|
73
|
+
private readonly _activeContainer;
|
|
74
|
+
readonly activeContainer: Signal<HTMLElement | null>;
|
|
75
|
+
/** Back-compat wrapper around `activate`. SSR-safe. */
|
|
76
|
+
init(options: MapInitOptions): Promise<void>;
|
|
77
|
+
activate(container: HTMLElement, options: MapInitOptions): void;
|
|
78
|
+
deactivate(container: HTMLElement): void;
|
|
79
|
+
private createMap;
|
|
80
|
+
/** Current map center as a `LngLat`. Prefer the `center` signal for reactive reads. */
|
|
81
|
+
getCenter(): mapboxgl.LngLat;
|
|
82
|
+
/** Current zoom level. Prefer the `zoom` signal for reactive reads. */
|
|
83
|
+
getZoom(): number;
|
|
84
|
+
/**
|
|
85
|
+
* Return the current viewport as a closed GeoJSON-style polygon ring
|
|
86
|
+
* (`[sw, se, ne, nw, sw]`). Useful for point-in-polygon queries against the
|
|
87
|
+
* visible area.
|
|
88
|
+
*/
|
|
89
|
+
getViewportPolygon(): Position[][];
|
|
90
|
+
/**
|
|
91
|
+
* Extract `properties` from the first feature under a click/hover event,
|
|
92
|
+
* cast to `T`. Returns `undefined` when no feature was hit or it has no props.
|
|
93
|
+
*/
|
|
94
|
+
getFeatureProperties<T>(mouseEvent: mapboxgl.MapMouseEvent): T | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Expand a cluster into its individual leaf features (up to `limit`, paginated
|
|
97
|
+
* via `offset`). Rejects if `sourceId` is missing or not a clustered GeoJSON source.
|
|
98
|
+
*/
|
|
99
|
+
getClusterProperties(sourceId: string, clusterId: number, limit?: number, offset?: number): Promise<mapboxgl.GeoJSONFeature[]>;
|
|
100
|
+
/**
|
|
101
|
+
* Query features rendered at a screen point, optionally restricted to specific layers.
|
|
102
|
+
* Returns `[]` when the map has not been initialised yet.
|
|
103
|
+
*/
|
|
104
|
+
getRenderedFeatures(point: mapboxgl.PointLike, params?: {
|
|
105
|
+
layers?: string[];
|
|
106
|
+
}): mapboxgl.GeoJSONFeature[];
|
|
107
|
+
/** Swap the base style. Custom sources/layers you added must be re-applied after `styledata`. */
|
|
108
|
+
setStyle(styleUrl: string): void;
|
|
109
|
+
/** Animate the camera to `center` at the given zoom (default 13). */
|
|
110
|
+
moveCenter(center: [number, number], zoom?: number): void;
|
|
111
|
+
/** Fit the viewport to `bounds` with optional pixel padding (default 40). */
|
|
112
|
+
fitBounds(bounds: mapboxgl.LngLatBoundsLike, padding?: number): void;
|
|
113
|
+
/**
|
|
114
|
+
* Add a GeoJSON source. Pass `clustered: true` and optional `clusterRadius`/`clusterMaxZoom`
|
|
115
|
+
* for point clustering. Set `generateId: true` when you plan to use feature-state.
|
|
116
|
+
*/
|
|
117
|
+
addSource(config: SourceConfig): void;
|
|
118
|
+
/** Replace the data of an existing GeoJSON source in place. No-op if the source is missing. */
|
|
119
|
+
updateSource(id: string, data: GeoJSON.FeatureCollection): void;
|
|
120
|
+
/**
|
|
121
|
+
* Add a layer to the style. Pass `beforeId` to insert the new layer beneath
|
|
122
|
+
* an existing one (useful for controlling draw order against style layers).
|
|
123
|
+
*/
|
|
124
|
+
addLayer(layer: LayerSpecification, beforeId?: string): void;
|
|
125
|
+
/**
|
|
126
|
+
* Add a raster layer backed by a source with the same id. Starts hidden —
|
|
127
|
+
* toggle with `toggleLayerVisibility(id)` or `setLayoutProperty`.
|
|
128
|
+
*/
|
|
129
|
+
addRasterLayer(id: string, _url: string): void;
|
|
130
|
+
/** Add a vector tile source from a TileJSON URL (typically `mapbox://...`). */
|
|
131
|
+
addVectorSource(id: string, url: string): void;
|
|
132
|
+
/**
|
|
133
|
+
* Add a heatmap layer bound to an existing source. `maxzoom` controls the
|
|
134
|
+
* zoom at which the heatmap fades out in favour of individual-point layers.
|
|
135
|
+
*/
|
|
136
|
+
addHeatmapLayer(config: {
|
|
137
|
+
id: string;
|
|
138
|
+
source: string;
|
|
139
|
+
maxzoom?: number;
|
|
140
|
+
paint: mapboxgl.HeatmapLayerSpecification['paint'];
|
|
141
|
+
}): void;
|
|
142
|
+
/**
|
|
143
|
+
* Apply a Mapbox filter expression to a layer, or pass `null` to clear it.
|
|
144
|
+
* Silently no-ops if the layer doesn't exist.
|
|
145
|
+
*/
|
|
146
|
+
setFilter(layerId: string, filter: unknown[] | null): void;
|
|
147
|
+
/**
|
|
148
|
+
* Change a paint property on any layer (color, opacity, width, etc.).
|
|
149
|
+
* Works on layers from the base style as well as layers you've added.
|
|
150
|
+
* Silently no-ops when the layer is missing so style swaps don't throw.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* map.setPaintProperty('road-primary', 'line-color', '#ff0080');
|
|
154
|
+
* map.setPaintProperty('water', 'fill-opacity', 0.6);
|
|
155
|
+
*/
|
|
156
|
+
setPaintProperty(layerId: string, name: string, value: unknown): void;
|
|
157
|
+
/**
|
|
158
|
+
* Change a layout property on any layer (visibility, icon-image, text-field, etc.).
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* map.setLayoutProperty('poi-label', 'visibility', 'none');
|
|
162
|
+
* map.setLayoutProperty('road-label', 'text-size', 14);
|
|
163
|
+
*/
|
|
164
|
+
setLayoutProperty(layerId: string, name: string, value: unknown): void;
|
|
165
|
+
/**
|
|
166
|
+
* Return every layer id currently in the style.
|
|
167
|
+
* Useful for discovering layer names from a custom Studio style so you can target them at runtime.
|
|
168
|
+
*/
|
|
169
|
+
getLayerIds(): string[];
|
|
170
|
+
/** `true` when a layer with this id exists in the current style. */
|
|
171
|
+
hasLayer(id: string): boolean;
|
|
172
|
+
/** `true` when a source with this id exists. */
|
|
173
|
+
hasSource(id: string): boolean;
|
|
174
|
+
/** Remove a layer if present. Useful during style swaps or layer teardown. */
|
|
175
|
+
safeRemoveLayer(id: string): void;
|
|
176
|
+
/** Convert geographic coordinates into pixel coordinates within the map container. */
|
|
177
|
+
project(lngLat: mapboxgl.LngLatLike): mapboxgl.Point;
|
|
178
|
+
/**
|
|
179
|
+
* Register an image for use with `icon-image` in symbol layers. Accepts
|
|
180
|
+
* either a pre-loaded `HTMLImageElement` or a URL to fetch. Updates an
|
|
181
|
+
* existing entry when the id is already registered.
|
|
182
|
+
*/
|
|
183
|
+
addImage(id: string, img: HTMLImageElement | string): Promise<void>;
|
|
184
|
+
/** Flip a layer's `visibility` between `'visible'` and `'none'`. */
|
|
185
|
+
toggleLayerVisibility(layerId: string): void;
|
|
186
|
+
/**
|
|
187
|
+
* Subscribe to a raw Mapbox event. Supports both the two-arg form
|
|
188
|
+
* (`on(event, handler)`) and the layer-scoped form (`on(event, layerId, handler)`).
|
|
189
|
+
*/
|
|
190
|
+
on(event: string, ...args: unknown[]): void;
|
|
191
|
+
/** Remove an event listener previously registered with `on`. */
|
|
192
|
+
off(event: string, ...args: unknown[]): void;
|
|
193
|
+
/** Remove a source from the style. Remove any layers using it first. */
|
|
194
|
+
removeSource(id: string): void;
|
|
195
|
+
/** Set arbitrary feature-state for a feature in a GeoJSON source. */
|
|
196
|
+
setFeatureState(sourceId: string, featureId: number | string, state: Record<string, unknown>): void;
|
|
197
|
+
/** Remove a specific feature-state key, or all state for the feature when `key` is omitted. */
|
|
198
|
+
clearFeatureState(sourceId: string, featureId: number | string, key?: string): void;
|
|
199
|
+
/**
|
|
200
|
+
* Enter polygon-drawing mode. Lazily mounts a `@mapbox/mapbox-gl-draw` control,
|
|
201
|
+
* hides its default UI (consumer controls the toggle), and switches to `draw_polygon`.
|
|
202
|
+
* The user clicks vertices and double-clicks (or clicks the first vertex) to close.
|
|
203
|
+
* The completed polygon is emitted on `polygonCreate`.
|
|
204
|
+
*/
|
|
205
|
+
enableDrawPolygon(): void;
|
|
206
|
+
/** Exit polygon-drawing mode and remove any in-progress or drawn polygons. */
|
|
207
|
+
disableDrawPolygon(): void;
|
|
208
|
+
/**
|
|
209
|
+
* Disable pan/zoom handlers so the viewport stays fixed while the user draws.
|
|
210
|
+
* Saves the prior enabled-state for each handler so it can be restored by
|
|
211
|
+
* `unlockInteractions`. Safe to call repeatedly — a second call is a no-op
|
|
212
|
+
* because saved state is only captured on the first lock.
|
|
213
|
+
*/
|
|
214
|
+
private lockInteractions;
|
|
215
|
+
/**
|
|
216
|
+
* Restore every pan/zoom handler to the enabled-state captured by
|
|
217
|
+
* `lockInteractions`. No-op when interactions were never locked.
|
|
218
|
+
*/
|
|
219
|
+
private unlockInteractions;
|
|
220
|
+
/** Remove every polygon the user has drawn, keeping draw mode active. */
|
|
221
|
+
clearDrawnPolygons(): void;
|
|
222
|
+
/** Fetch a URL into an `HTMLImageElement`. Resolves on `load`, rejects on `error`. */
|
|
223
|
+
private loadImage;
|
|
224
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MapboxService, never>;
|
|
225
|
+
static ɵprov: _angular_core.ɵɵInjectableDeclaration<MapboxService>;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Thin host component that mounts a Mapbox map into a container div, forwards
|
|
230
|
+
* lifecycle/events from `MapboxService`, and cleans up on destroy.
|
|
231
|
+
*
|
|
232
|
+
* Consumers interact with the underlying map via the public `map` (MapboxService)
|
|
233
|
+
* instance — use `viewChild(ApexMapComponent)` in a parent to reach `component.map`
|
|
234
|
+
* and call `addSource()`, `addLayer()`, `moveCenter()`, etc.
|
|
235
|
+
*
|
|
236
|
+
* Example:
|
|
237
|
+
* <apex-map [center]="[-80.84, 35.22]" [zoom]="11" (mapReady)="onReady()"/>
|
|
238
|
+
*/
|
|
239
|
+
declare class ApexMapComponent {
|
|
240
|
+
center: _angular_core.InputSignal<[number, number]>;
|
|
241
|
+
zoom: _angular_core.InputSignal<number>;
|
|
242
|
+
mapStyle: _angular_core.InputSignal<string | StyleSpecification | undefined>;
|
|
243
|
+
maxBounds: _angular_core.InputSignal<mapbox_gl.LngLatBoundsLike | undefined>;
|
|
244
|
+
showNavigation: _angular_core.InputSignal<boolean>;
|
|
245
|
+
mapReady: _angular_core.OutputEmitterRef<void>;
|
|
246
|
+
mapClick: _angular_core.OutputEmitterRef<mapbox_gl.MapMouseEvent>;
|
|
247
|
+
featureClick: _angular_core.OutputEmitterRef<mapbox_gl.MapMouseEvent>;
|
|
248
|
+
readonly map: MapboxService;
|
|
249
|
+
private readonly platformId;
|
|
250
|
+
private readonly destroyRef;
|
|
251
|
+
private readonly container;
|
|
252
|
+
/**
|
|
253
|
+
* Wire a reactive effect that emits `mapReady` once the underlying Mapbox
|
|
254
|
+
* `load` event fires and `MapboxService.ready()` flips to `true`.
|
|
255
|
+
*/
|
|
256
|
+
constructor();
|
|
257
|
+
/**
|
|
258
|
+
* Initialise the Mapbox instance into the `#container` div, forward
|
|
259
|
+
* `mapClick`/`featureClick` streams as component outputs, and register
|
|
260
|
+
* teardown so the map is destroyed with the component.
|
|
261
|
+
* No-op on non-browser platforms (SSR).
|
|
262
|
+
*/
|
|
263
|
+
ngAfterViewInit(): void;
|
|
264
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<ApexMapComponent, never>;
|
|
265
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<ApexMapComponent, "apex-map", never, { "center": { "alias": "center"; "required": false; "isSignal": true; }; "zoom": { "alias": "zoom"; "required": false; "isSignal": true; }; "mapStyle": { "alias": "mapStyle"; "required": false; "isSignal": true; }; "maxBounds": { "alias": "maxBounds"; "required": false; "isSignal": true; }; "showNavigation": { "alias": "showNavigation"; "required": false; "isSignal": true; }; }, { "mapReady": "mapReady"; "mapClick": "mapClick"; "featureClick": "featureClick"; }, never, never, true, never>;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
interface MapConfig {
|
|
269
|
+
/** Mapbox public access token (pk.*). Required. */
|
|
270
|
+
accessToken: string;
|
|
271
|
+
/**
|
|
272
|
+
* Default style applied when a consumer doesn't pass `mapStyle` to init.
|
|
273
|
+
* Accepts a style URL, a `MapStyles` enum value, or a full inline `StyleSpecification`.
|
|
274
|
+
*/
|
|
275
|
+
defaultStyle?: MapStyles | string | StyleSpecification;
|
|
276
|
+
}
|
|
277
|
+
declare const MAP_CONFIG: InjectionToken<MapConfig>;
|
|
278
|
+
/**
|
|
279
|
+
* Register @apexara/map at the application root.
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* // app.config.ts
|
|
283
|
+
* providers: [
|
|
284
|
+
* provideMap({ accessToken: environment.mapboxToken }),
|
|
285
|
+
* ]
|
|
286
|
+
*/
|
|
287
|
+
declare function provideMap(config: MapConfig): EnvironmentProviders;
|
|
288
|
+
|
|
289
|
+
type Coord = [number, number];
|
|
290
|
+
/**
|
|
291
|
+
* Recursively flatten any nesting of GeoJSON coordinates down to a flat list of [lng, lat] pairs.
|
|
292
|
+
* Handles Point, LineString, Polygon, and MultiPolygon coordinate shapes uniformly.
|
|
293
|
+
*/
|
|
294
|
+
declare function flattenCoords(arr: Coord | Coord[] | Coord[][] | Coord[][][]): Coord[];
|
|
295
|
+
/**
|
|
296
|
+
* Compute the [[minLng, minLat], [maxLng, maxLat]] bounds of a flat list of coordinates.
|
|
297
|
+
* Return value is compatible with `mapboxgl.LngLatBoundsLike`.
|
|
298
|
+
*/
|
|
299
|
+
declare function calculateBounds(coords: Coord[]): mapboxgl.LngLatBoundsLike;
|
|
300
|
+
/**
|
|
301
|
+
* Build a closed square polygon of side `2 * radiusKm` centered at `center`.
|
|
302
|
+
* Useful when you need a small viewport-like polygon for point-in-polygon queries.
|
|
303
|
+
*/
|
|
304
|
+
declare function calculateViewportPolygonFromCenter(center: Coord, radiusKm?: number): number[][][];
|
|
305
|
+
|
|
306
|
+
export { ApexMapComponent, MAP_CONFIG, MapStyles, MapboxService, calculateBounds, calculateViewportPolygonFromCenter, flattenCoords, provideMap };
|
|
307
|
+
export type { MapConfig, MapInitOptions, SourceConfig };
|