@apexara/map 1.0.0 → 1.1.1
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 +75 -4
- package/fesm2022/apexara-map-config.mjs +34 -0
- package/fesm2022/apexara-map-config.mjs.map +1 -0
- package/fesm2022/apexara-map.mjs +76 -32
- package/fesm2022/apexara-map.mjs.map +1 -1
- package/package.json +5 -1
- package/types/apexara-map-config.d.ts +35 -0
- package/types/apexara-map.d.ts +32 -33
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@ A thin, opinionated Angular wrapper around [Mapbox GL JS](https://docs.mapbox.co
|
|
|
16
16
|
- [The component: `<apex-map>`](#the-component-apex-map)
|
|
17
17
|
- [The service: `MapboxService`](#the-service-mapboxservice)
|
|
18
18
|
- [Reactive state (signals)](#reactive-state-signals)
|
|
19
|
+
- [The raw map & style readiness](#the-raw-map--style-readiness)
|
|
19
20
|
- [Viewport & camera](#viewport--camera)
|
|
20
21
|
- [Sources](#sources)
|
|
21
22
|
- [Layers](#layers)
|
|
@@ -52,11 +53,15 @@ You also need Mapbox's CSS once in your app (usually in `styles.css`):
|
|
|
52
53
|
## Configure
|
|
53
54
|
|
|
54
55
|
Register the library at the application root with `provideMap`, passing your Mapbox public access token (`pk.*`).
|
|
56
|
+
Import it from **`@apexara/map/config`**: that entry point holds only the config (`provideMap`, `MAP_CONFIG`,
|
|
57
|
+
`MapConfig`, `MapStyles`) and imports neither `mapbox-gl` nor `@mapbox/mapbox-gl-draw`, so the root config does not
|
|
58
|
+
pull ~2 MB of map code into the app's first download. The map then loads with the routes that show one. The main
|
|
59
|
+
entry `@apexara/map` re-exports the same token, so `MapboxService` reads what `provideMap` provided.
|
|
55
60
|
|
|
56
61
|
```ts
|
|
57
62
|
// app.config.ts
|
|
58
63
|
import { ApplicationConfig } from '@angular/core';
|
|
59
|
-
import { provideMap, MapStyles } from '@apexara/map';
|
|
64
|
+
import { provideMap, MapStyles } from '@apexara/map/config';
|
|
60
65
|
import { environment } from './environments/environment';
|
|
61
66
|
|
|
62
67
|
export const appConfig: ApplicationConfig = {
|
|
@@ -189,6 +194,40 @@ constructor() {
|
|
|
189
194
|
| `bounds` | `Signal<[[number, number], [number, number]] \| null>` | `[[swLng, swLat], [neLng, neLat]]`. On `moveend`. |
|
|
190
195
|
| `isMoving` | `Signal<boolean>` | `true` between `movestart` and `moveend`. |
|
|
191
196
|
|
|
197
|
+
### The raw map & style readiness
|
|
198
|
+
|
|
199
|
+
One `mapboxgl.Map` serves every consumer: the service re-parents it between containers (`activate` / `deactivate`)
|
|
200
|
+
instead of building a new one.
|
|
201
|
+
|
|
202
|
+
- `isSupported()` — whether this browser can run mapbox (WebGL2, workers, canvas reads). Asked once and kept; `false`
|
|
203
|
+
on the server. Check it before taking the map from another container.
|
|
204
|
+
- `activate(container, options)` — puts the map on `container` and returns `true`. Returns `false` when it did not
|
|
205
|
+
start: on the server, when `isSupported()` is false, or when the first start throws (some browsers pass the check
|
|
206
|
+
and still fail, e.g. at their limit of WebGL contexts). A failed start takes its host div back out of the container
|
|
207
|
+
and logs the error, so the consumer shows its own message in the box instead of a blank page. An error from a map
|
|
208
|
+
that is already running (a bad centre on a hand-off) still throws.
|
|
209
|
+
- `getMap()` — the live `mapboxgl.Map`, for mapbox APIs the service does not wrap (`jumpTo` with event data,
|
|
210
|
+
`getCanvas`, `scrollZoom`, …). `undefined` until the first `init` / `activate`. Use it instead of reaching into the
|
|
211
|
+
service's private field.
|
|
212
|
+
- `whenStyleReady(destroyRef?)` — resolves once the style is parsed, which is what `addSource` / `addLayer` need.
|
|
213
|
+
`ready()` is a one-time latch on the first `load`: after a re-parent or a `setStyle` it says nothing about the
|
|
214
|
+
style. Resolves at once when there is no map yet or the style is parsed; otherwise on `style.load`, or on `idle` when
|
|
215
|
+
`style.load` already fired. Pass the caller's `DestroyRef` so a caller torn down mid-wait resolves instead of
|
|
216
|
+
hanging.
|
|
217
|
+
|
|
218
|
+
```ts
|
|
219
|
+
private readonly map = inject(MapboxService);
|
|
220
|
+
private readonly destroyRef = inject(DestroyRef);
|
|
221
|
+
|
|
222
|
+
async addMyLayers(): Promise<void> {
|
|
223
|
+
await this.map.whenStyleReady(this.destroyRef);
|
|
224
|
+
|
|
225
|
+
if (!this.map.hasSource('stops')) {
|
|
226
|
+
this.map.addSource({ id: 'stops', data: geojson });
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
192
231
|
### Viewport & camera
|
|
193
232
|
|
|
194
233
|
- `init(options)` — create the underlying map. Called automatically by `<apex-map>`; call yourself only if you're managing your own container.
|
|
@@ -308,11 +347,30 @@ await map.addImage('stop-pin', '/assets/stop-pin.png'); // URL or HTMLImageEleme
|
|
|
308
347
|
// then reference in a symbol layer: { 'icon-image': 'stop-pin' }
|
|
309
348
|
```
|
|
310
349
|
|
|
311
|
-
Re-calling with an existing id updates the image in place.
|
|
350
|
+
Re-calling with an existing id updates the image in place (same size, options kept).
|
|
351
|
+
|
|
352
|
+
For a sprite you draw yourself (a canvas baked at the screen's pixel ratio, a stretchable pill), use `replaceImage`:
|
|
353
|
+
it removes any image already under the id and adds the new one, so its size and options may change.
|
|
354
|
+
|
|
355
|
+
```ts
|
|
356
|
+
const pixels = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
357
|
+
|
|
358
|
+
map.replaceImage('price-pill', pixels, {
|
|
359
|
+
pixelRatio: 2,
|
|
360
|
+
stretchX: [[20, 30]],
|
|
361
|
+
content: [16, 4, 48, 24],
|
|
362
|
+
});
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
`image` takes whatever `mapboxgl.Map.addImage` takes (`MapImageSource`); `options` is `MapImageOptions`
|
|
366
|
+
(`pixelRatio`, `sdf`, `stretchX` / `stretchY`, `content`). Re-register after a `setStyle` that replaces the style: the
|
|
367
|
+
runtime images go with it.
|
|
312
368
|
|
|
313
369
|
### Teardown
|
|
314
370
|
|
|
315
|
-
|
|
371
|
+
The shared map is never destroyed. `deactivate(container)` takes it off `container`: it moves back to the container
|
|
372
|
+
that held it before, or waits hidden until the next `activate`. `<apex-map>` calls it through `DestroyRef`, so call it
|
|
373
|
+
yourself only for a container you passed to `activate()` / `init()`.
|
|
316
374
|
|
|
317
375
|
---
|
|
318
376
|
|
|
@@ -334,7 +392,8 @@ map.fitBounds(bounds, 60);
|
|
|
334
392
|
const ring = calculateViewportPolygonFromCenter([-80.84, 35.22], 0.5);
|
|
335
393
|
```
|
|
336
394
|
|
|
337
|
-
- `flattenCoords(arr)` — flatten any GeoJSON coordinate nesting into `[lng, lat][]`.
|
|
395
|
+
- `flattenCoords(arr)` — flatten any GeoJSON coordinate nesting into `[lng, lat][]`. Takes a geometry's
|
|
396
|
+
`coordinates` as they are (`Position`, `Position[]`, `Position[][]`, `Position[][][]`), no cast needed.
|
|
338
397
|
- `calculateBounds(coords)` — `[[minLng, minLat], [maxLng, maxLat]]`, compatible with `LngLatBoundsLike`.
|
|
339
398
|
- `calculateViewportPolygonFromCenter(center, radiusKm = 0.5)` — a closed square ring around `center`.
|
|
340
399
|
|
|
@@ -343,19 +402,29 @@ const ring = calculateViewportPolygonFromCenter([-80.84, 35.22], 0.5);
|
|
|
343
402
|
## Types & tokens
|
|
344
403
|
|
|
345
404
|
```ts
|
|
405
|
+
// No mapbox-gl at runtime: safe in the app's root config.
|
|
346
406
|
import {
|
|
347
407
|
provideMap,
|
|
348
408
|
MAP_CONFIG,
|
|
349
409
|
type MapConfig,
|
|
350
410
|
MapStyles,
|
|
411
|
+
} from '@apexara/map/config';
|
|
412
|
+
|
|
413
|
+
// The map itself (loads mapbox-gl).
|
|
414
|
+
import {
|
|
415
|
+
type MapImageOptions,
|
|
416
|
+
type MapImageSource,
|
|
351
417
|
type MapInitOptions,
|
|
352
418
|
type SourceConfig,
|
|
353
419
|
} from '@apexara/map';
|
|
354
420
|
```
|
|
355
421
|
|
|
422
|
+
`@apexara/map` re-exports everything `@apexara/map/config` holds (one token, not a copy), so 1.0.0 imports keep working.
|
|
423
|
+
|
|
356
424
|
- `MapStyles` — enum of common Mapbox-hosted styles (`Streets`, `Sat`, `DarkV11`, `LightV11`, `OutdoorsV12`).
|
|
357
425
|
- `MapInitOptions` — shape accepted by `MapboxService.init` (the component builds this for you).
|
|
358
426
|
- `SourceConfig` — shape accepted by `addSource` (GeoJSON + clustering flags).
|
|
427
|
+
- `MapImageSource` / `MapImageOptions` — what `replaceImage` accepts (the image and `addImage`'s options).
|
|
359
428
|
- `MapConfig` / `MAP_CONFIG` — root-level token, usually set via `provideMap`.
|
|
360
429
|
|
|
361
430
|
---
|
|
@@ -409,6 +478,7 @@ map.setStyle(MapStyles.DarkV11);
|
|
|
409
478
|
## SSR notes
|
|
410
479
|
|
|
411
480
|
- `MapboxService.init` is a no-op on the server, and `<apex-map>` guards its `ngAfterViewInit` with `isPlatformBrowser`, so the component renders an empty container during SSR without throwing.
|
|
481
|
+
- `activate` returns `false` on the server and `isSupported()` is `false` there: a consumer that shows a "can't show maps" message on `false` should show it only in the browser.
|
|
412
482
|
- Avoid calling mutating methods (`addSource`, `addLayer`, etc.) during SSR — gate them on `map.ready()`.
|
|
413
483
|
|
|
414
484
|
---
|
|
@@ -416,6 +486,7 @@ map.setStyle(MapStyles.DarkV11);
|
|
|
416
486
|
## Troubleshooting
|
|
417
487
|
|
|
418
488
|
- **Blank map** — the container has no height. Give `<apex-map>` an explicit size.
|
|
489
|
+
- **`activate` returns `false` in a browser** — the browser cannot run mapbox (no WebGL2, hardware acceleration off) or the first start failed; the console shows `[@apexara/map] The map failed to start.` with mapbox's error for the second case.
|
|
419
490
|
- **`401 Unauthorized` tiles** — the access token passed to `provideMap` is wrong or not a public (`pk.*`) token.
|
|
420
491
|
- **Sources/layers disappear after `setStyle`** — Mapbox replaces the entire style. Re-add them in a `styledata` listener.
|
|
421
492
|
- **`setFeatureState` does nothing** — the source was added without `generateId: true` and features have no numeric `id`.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { InjectionToken, makeEnvironmentProviders } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
const MAP_CONFIG = new InjectionToken('APEX_MAP_CONFIG');
|
|
4
|
+
/**
|
|
5
|
+
* Register @apexara/map at the application root.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* // app.config.ts
|
|
9
|
+
* providers: [
|
|
10
|
+
* provideMap({ accessToken: environment.mapboxToken }),
|
|
11
|
+
* ]
|
|
12
|
+
*/
|
|
13
|
+
function provideMap(config) {
|
|
14
|
+
return makeEnvironmentProviders([{ provide: MAP_CONFIG, useValue: config }]);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Mapbox-hosted base styles, for `MapConfig.defaultStyle` or `<apex-map [mapStyle]>`. */
|
|
18
|
+
var MapStyles;
|
|
19
|
+
(function (MapStyles) {
|
|
20
|
+
MapStyles["Sat"] = "mapbox://styles/mapbox/satellite-streets-v12";
|
|
21
|
+
MapStyles["Streets"] = "mapbox://styles/mapbox/streets-v12";
|
|
22
|
+
MapStyles["DarkV11"] = "mapbox://styles/mapbox/dark-v11";
|
|
23
|
+
MapStyles["LightV11"] = "mapbox://styles/mapbox/light-v11";
|
|
24
|
+
MapStyles["OutdoorsV12"] = "mapbox://styles/mapbox/outdoors-v12";
|
|
25
|
+
})(MapStyles || (MapStyles = {}));
|
|
26
|
+
|
|
27
|
+
// No runtime import of mapbox-gl or mapbox-gl-draw here: an app's root config imports this entry, not the map.
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Generated bundle index. Do not edit.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
export { MAP_CONFIG, MapStyles, provideMap };
|
|
34
|
+
//# sourceMappingURL=apexara-map-config.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apexara-map-config.mjs","sources":["../../../../projects/apexara/map/config/src/map.tokens.ts","../../../../projects/apexara/map/config/src/map.styles.ts","../../../../projects/apexara/map/config/public-api.ts","../../../../projects/apexara/map/config/apexara-map-config.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.styles';\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","/** Mapbox-hosted base styles, for `MapConfig.defaultStyle` or `<apex-map [mapStyle]>`. */\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","// No runtime import of mapbox-gl or mapbox-gl-draw here: an app's root config imports this entry, not the map.\nexport { MAP_CONFIG, provideMap, type MapConfig } from './src/map.tokens';\nexport { MapStyles } from './src/map.styles';\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;;ACjCA;IACY;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;;ACDrB;;ACAA;;AAEG;;;;"}
|
package/fesm2022/apexara-map.mjs
CHANGED
|
@@ -1,33 +1,12 @@
|
|
|
1
1
|
import { isPlatformBrowser } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import {
|
|
3
|
+
import { signal, inject, PLATFORM_ID, Injectable, input, output, DestroyRef, viewChild, effect, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
4
4
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
5
5
|
import { Subject } from 'rxjs';
|
|
6
6
|
import MapboxDraw from '@mapbox/mapbox-gl-draw';
|
|
7
7
|
import mapboxgl from 'mapbox-gl';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Register @apexara/map at the application root.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* // app.config.ts
|
|
15
|
-
* providers: [
|
|
16
|
-
* provideMap({ accessToken: environment.mapboxToken }),
|
|
17
|
-
* ]
|
|
18
|
-
*/
|
|
19
|
-
function provideMap(config) {
|
|
20
|
-
return makeEnvironmentProviders([{ provide: MAP_CONFIG, useValue: config }]);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
var MapStyles;
|
|
24
|
-
(function (MapStyles) {
|
|
25
|
-
MapStyles["Sat"] = "mapbox://styles/mapbox/satellite-streets-v12";
|
|
26
|
-
MapStyles["Streets"] = "mapbox://styles/mapbox/streets-v12";
|
|
27
|
-
MapStyles["DarkV11"] = "mapbox://styles/mapbox/dark-v11";
|
|
28
|
-
MapStyles["LightV11"] = "mapbox://styles/mapbox/light-v11";
|
|
29
|
-
MapStyles["OutdoorsV12"] = "mapbox://styles/mapbox/outdoors-v12";
|
|
30
|
-
})(MapStyles || (MapStyles = {}));
|
|
8
|
+
import { MAP_CONFIG, MapStyles } from '@apexara/map/config';
|
|
9
|
+
export { MAP_CONFIG, MapStyles, provideMap } from '@apexara/map/config';
|
|
31
10
|
|
|
32
11
|
/**
|
|
33
12
|
* Mapbox Service — wrapper around a `mapboxgl.Map` instance.
|
|
@@ -77,6 +56,8 @@ class MapboxService {
|
|
|
77
56
|
this.containerStack = [];
|
|
78
57
|
this._activeContainer = signal(null, ...(ngDevMode ? [{ debugName: "_activeContainer" }] : []));
|
|
79
58
|
this.activeContainer = this._activeContainer;
|
|
59
|
+
// Whether this browser can run mapbox; null until asked. Kept, since mapbox's check builds a worker and a canvas.
|
|
60
|
+
this.supported = null;
|
|
80
61
|
}
|
|
81
62
|
/** Back-compat wrapper around `activate`. SSR-safe. */
|
|
82
63
|
async init(options) {
|
|
@@ -85,15 +66,21 @@ class MapboxService {
|
|
|
85
66
|
}
|
|
86
67
|
this.activate(options.container, options);
|
|
87
68
|
}
|
|
69
|
+
/** Whether this browser can run mapbox (WebGL2, workers, canvas reads). Asked once; false on the server. */
|
|
70
|
+
isSupported() {
|
|
71
|
+
this.supported ??= isPlatformBrowser(this.platformId) && mapboxgl.supported();
|
|
72
|
+
return this.supported;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Puts the shared map on `container`. False when it did not start there: on the server, in a browser that cannot run
|
|
76
|
+
* mapbox, or when the first start throws (undone and reported). A running map's errors still throw.
|
|
77
|
+
*/
|
|
88
78
|
activate(container, options) {
|
|
89
|
-
if (!
|
|
90
|
-
return;
|
|
79
|
+
if (!this.isSupported()) {
|
|
80
|
+
return false;
|
|
91
81
|
}
|
|
92
82
|
if (!this.mapInitialised) {
|
|
93
|
-
this.
|
|
94
|
-
this.containerStack.push(container);
|
|
95
|
-
this._activeContainer.set(container);
|
|
96
|
-
return;
|
|
83
|
+
return this.startMap(container, options);
|
|
97
84
|
}
|
|
98
85
|
const active = this._activeContainer();
|
|
99
86
|
if (active === container) {
|
|
@@ -101,7 +88,7 @@ class MapboxService {
|
|
|
101
88
|
this.map.jumpTo({ center: options.center, zoom: options.zoom ?? this.map.getZoom() });
|
|
102
89
|
}
|
|
103
90
|
requestAnimationFrame(() => this.map.resize());
|
|
104
|
-
return;
|
|
91
|
+
return true;
|
|
105
92
|
}
|
|
106
93
|
this.hostDiv?.remove();
|
|
107
94
|
if (this.hostDiv) {
|
|
@@ -115,6 +102,7 @@ class MapboxService {
|
|
|
115
102
|
this.map.jumpTo({ center: options.center, zoom: options.zoom ?? this.map.getZoom() });
|
|
116
103
|
}
|
|
117
104
|
requestAnimationFrame(() => this.map.resize());
|
|
105
|
+
return true;
|
|
118
106
|
}
|
|
119
107
|
deactivate(container) {
|
|
120
108
|
if (!isPlatformBrowser(this.platformId)) {
|
|
@@ -140,6 +128,22 @@ class MapboxService {
|
|
|
140
128
|
}
|
|
141
129
|
this._activeContainer.set(null);
|
|
142
130
|
}
|
|
131
|
+
// The first start. It can pass isSupported and still throw (e.g. at the browser's limit of WebGL contexts) after its
|
|
132
|
+
// host div went into the container: the div comes back out, so the container is left as it was.
|
|
133
|
+
startMap(container, options) {
|
|
134
|
+
try {
|
|
135
|
+
this.createMap(container, options);
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
this.hostDiv?.remove();
|
|
139
|
+
this.hostDiv = null;
|
|
140
|
+
console.error('[@apexara/map] The map failed to start.', error);
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
this.containerStack.push(container);
|
|
144
|
+
this._activeContainer.set(container);
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
143
147
|
createMap(container, options) {
|
|
144
148
|
const defaultBounds = [
|
|
145
149
|
[-175, -85],
|
|
@@ -203,6 +207,32 @@ class MapboxService {
|
|
|
203
207
|
getZoom() {
|
|
204
208
|
return this.map.getZoom();
|
|
205
209
|
}
|
|
210
|
+
/** The live `mapboxgl.Map`, for mapbox APIs this service does not wrap. `undefined` until the first `init`/`activate`. */
|
|
211
|
+
getMap() {
|
|
212
|
+
return this.mapInitialised ? this.map : undefined;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Resolves once the style is parsed, so sources and layers can be added: after a re-parent `ready()` (a one-time
|
|
216
|
+
* latch) says nothing about that. Resolves at once with no map; pass `destroyRef` to resolve on teardown, not hang.
|
|
217
|
+
*/
|
|
218
|
+
whenStyleReady(destroyRef) {
|
|
219
|
+
if (!this.mapInitialised || this.isStyleParsed()) {
|
|
220
|
+
return Promise.resolve();
|
|
221
|
+
}
|
|
222
|
+
return new Promise((resolve) => {
|
|
223
|
+
let removeDestroyHook;
|
|
224
|
+
const done = () => {
|
|
225
|
+
this.map.off('style.load', done);
|
|
226
|
+
this.map.off('idle', done);
|
|
227
|
+
removeDestroyHook?.();
|
|
228
|
+
resolve();
|
|
229
|
+
};
|
|
230
|
+
// `idle` always fires once the map settles, so a `style.load` that already fired cannot hang the wait.
|
|
231
|
+
this.map.once('style.load', done);
|
|
232
|
+
this.map.once('idle', done);
|
|
233
|
+
removeDestroyHook = destroyRef?.onDestroy(done);
|
|
234
|
+
});
|
|
235
|
+
}
|
|
206
236
|
/**
|
|
207
237
|
* Return the current viewport as a closed GeoJSON-style polygon ring
|
|
208
238
|
* (`[sw, se, ne, nw, sw]`). Useful for point-in-polygon queries against the
|
|
@@ -432,6 +462,16 @@ class MapboxService {
|
|
|
432
462
|
}
|
|
433
463
|
this.map.updateImage(id, imgEl);
|
|
434
464
|
}
|
|
465
|
+
/**
|
|
466
|
+
* Register `image` under `id`, replacing any image already there. Unlike `addImage`'s in-place update, the size and
|
|
467
|
+
* the options (`pixelRatio`, `stretchX` / `stretchY`, `content`) may change, as a re-baked canvas sprite needs.
|
|
468
|
+
*/
|
|
469
|
+
replaceImage(id, image, options) {
|
|
470
|
+
if (this.map.hasImage(id)) {
|
|
471
|
+
this.map.removeImage(id);
|
|
472
|
+
}
|
|
473
|
+
this.map.addImage(id, image, options);
|
|
474
|
+
}
|
|
435
475
|
/** Flip a layer's `visibility` between `'visible'` and `'none'`. */
|
|
436
476
|
toggleLayerVisibility(layerId) {
|
|
437
477
|
const vis = this.map.getLayoutProperty(layerId, 'visibility');
|
|
@@ -561,6 +601,10 @@ class MapboxService {
|
|
|
561
601
|
clearDrawnPolygons() {
|
|
562
602
|
this.draw?.deleteAll();
|
|
563
603
|
}
|
|
604
|
+
/** `isStyleLoaded()` also waits for tiles; what addSource needs is mapbox's one-shot "style parsed" flag. */
|
|
605
|
+
isStyleParsed() {
|
|
606
|
+
return this.map.isStyleLoaded() || !!this.map.style?._loaded;
|
|
607
|
+
}
|
|
564
608
|
/** Fetch a URL into an `HTMLImageElement`. Resolves on `load`, rejects on `error`. */
|
|
565
609
|
loadImage(url) {
|
|
566
610
|
return new Promise((res, rej) => {
|
|
@@ -716,5 +760,5 @@ function calculateViewportPolygonFromCenter(center, radiusKm = 0.5) {
|
|
|
716
760
|
* Generated bundle index. Do not edit.
|
|
717
761
|
*/
|
|
718
762
|
|
|
719
|
-
export { ApexMapComponent,
|
|
763
|
+
export { ApexMapComponent, MapboxService, calculateBounds, calculateViewportPolygonFromCenter, flattenCoords };
|
|
720
764
|
//# sourceMappingURL=apexara-map.mjs.map
|
|
@@ -1 +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 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AQ,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;;;;"}
|
|
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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angular/common": ">=21.2.0",
|
|
@@ -37,6 +37,10 @@
|
|
|
37
37
|
".": {
|
|
38
38
|
"types": "./types/apexara-map.d.ts",
|
|
39
39
|
"default": "./fesm2022/apexara-map.mjs"
|
|
40
|
+
},
|
|
41
|
+
"./config": {
|
|
42
|
+
"types": "./types/apexara-map-config.d.ts",
|
|
43
|
+
"default": "./fesm2022/apexara-map-config.mjs"
|
|
40
44
|
}
|
|
41
45
|
}
|
|
42
46
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { InjectionToken, EnvironmentProviders } from '@angular/core';
|
|
2
|
+
import { StyleSpecification } from 'mapbox-gl';
|
|
3
|
+
|
|
4
|
+
/** Mapbox-hosted base styles, for `MapConfig.defaultStyle` or `<apex-map [mapStyle]>`. */
|
|
5
|
+
declare enum MapStyles {
|
|
6
|
+
Sat = "mapbox://styles/mapbox/satellite-streets-v12",
|
|
7
|
+
Streets = "mapbox://styles/mapbox/streets-v12",
|
|
8
|
+
DarkV11 = "mapbox://styles/mapbox/dark-v11",
|
|
9
|
+
LightV11 = "mapbox://styles/mapbox/light-v11",
|
|
10
|
+
OutdoorsV12 = "mapbox://styles/mapbox/outdoors-v12"
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface MapConfig {
|
|
14
|
+
/** Mapbox public access token (pk.*). Required. */
|
|
15
|
+
accessToken: string;
|
|
16
|
+
/**
|
|
17
|
+
* Default style applied when a consumer doesn't pass `mapStyle` to init.
|
|
18
|
+
* Accepts a style URL, a `MapStyles` enum value, or a full inline `StyleSpecification`.
|
|
19
|
+
*/
|
|
20
|
+
defaultStyle?: MapStyles | string | StyleSpecification;
|
|
21
|
+
}
|
|
22
|
+
declare const MAP_CONFIG: InjectionToken<MapConfig>;
|
|
23
|
+
/**
|
|
24
|
+
* Register @apexara/map at the application root.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // app.config.ts
|
|
28
|
+
* providers: [
|
|
29
|
+
* provideMap({ accessToken: environment.mapboxToken }),
|
|
30
|
+
* ]
|
|
31
|
+
*/
|
|
32
|
+
declare function provideMap(config: MapConfig): EnvironmentProviders;
|
|
33
|
+
|
|
34
|
+
export { MAP_CONFIG, MapStyles, provideMap };
|
|
35
|
+
export type { MapConfig };
|
package/types/apexara-map.d.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import * as mapbox_gl from 'mapbox-gl';
|
|
2
2
|
import { LayerSpecification, StyleSpecification } from 'mapbox-gl';
|
|
3
3
|
import * as _angular_core from '@angular/core';
|
|
4
|
-
import { Signal, WritableSignal,
|
|
4
|
+
import { Signal, WritableSignal, DestroyRef } from '@angular/core';
|
|
5
5
|
import { Subject } from 'rxjs';
|
|
6
6
|
import * as GeoJSON from 'geojson';
|
|
7
7
|
import { Position } from 'geojson';
|
|
8
|
+
export { MAP_CONFIG, MapConfig, MapStyles, provideMap } from '@apexara/map/config';
|
|
8
9
|
|
|
10
|
+
/** An image `MapboxService.replaceImage` registers: whatever `mapboxgl.Map.addImage` takes (`ImageData`, an `<img>`, …). */
|
|
11
|
+
type MapImageSource = Parameters<mapboxgl.Map['addImage']>[1];
|
|
12
|
+
/** Its options: `pixelRatio`, `sdf`, `stretchX` / `stretchY`, `content`. */
|
|
13
|
+
type MapImageOptions = Parameters<mapboxgl.Map['addImage']>[2];
|
|
9
14
|
interface MapInitOptions {
|
|
10
15
|
/** DOM element the map renders into. */
|
|
11
16
|
container: HTMLElement;
|
|
@@ -35,13 +40,6 @@ interface SourceConfig {
|
|
|
35
40
|
/** When true, Mapbox auto-generates a stable numeric `id` per feature — required for feature-state APIs. */
|
|
36
41
|
generateId?: boolean;
|
|
37
42
|
}
|
|
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
43
|
|
|
46
44
|
declare class MapboxService {
|
|
47
45
|
/** Click on empty canvas (no features under the cursor). Event stream. */
|
|
@@ -72,15 +70,30 @@ declare class MapboxService {
|
|
|
72
70
|
private containerStack;
|
|
73
71
|
private readonly _activeContainer;
|
|
74
72
|
readonly activeContainer: Signal<HTMLElement | null>;
|
|
73
|
+
private supported;
|
|
75
74
|
/** Back-compat wrapper around `activate`. SSR-safe. */
|
|
76
75
|
init(options: MapInitOptions): Promise<void>;
|
|
77
|
-
|
|
76
|
+
/** Whether this browser can run mapbox (WebGL2, workers, canvas reads). Asked once; false on the server. */
|
|
77
|
+
isSupported(): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Puts the shared map on `container`. False when it did not start there: on the server, in a browser that cannot run
|
|
80
|
+
* mapbox, or when the first start throws (undone and reported). A running map's errors still throw.
|
|
81
|
+
*/
|
|
82
|
+
activate(container: HTMLElement, options: MapInitOptions): boolean;
|
|
78
83
|
deactivate(container: HTMLElement): void;
|
|
84
|
+
private startMap;
|
|
79
85
|
private createMap;
|
|
80
86
|
/** Current map center as a `LngLat`. Prefer the `center` signal for reactive reads. */
|
|
81
87
|
getCenter(): mapboxgl.LngLat;
|
|
82
88
|
/** Current zoom level. Prefer the `zoom` signal for reactive reads. */
|
|
83
89
|
getZoom(): number;
|
|
90
|
+
/** The live `mapboxgl.Map`, for mapbox APIs this service does not wrap. `undefined` until the first `init`/`activate`. */
|
|
91
|
+
getMap(): mapboxgl.Map | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Resolves once the style is parsed, so sources and layers can be added: after a re-parent `ready()` (a one-time
|
|
94
|
+
* latch) says nothing about that. Resolves at once with no map; pass `destroyRef` to resolve on teardown, not hang.
|
|
95
|
+
*/
|
|
96
|
+
whenStyleReady(destroyRef?: DestroyRef): Promise<void>;
|
|
84
97
|
/**
|
|
85
98
|
* Return the current viewport as a closed GeoJSON-style polygon ring
|
|
86
99
|
* (`[sw, se, ne, nw, sw]`). Useful for point-in-polygon queries against the
|
|
@@ -181,6 +194,11 @@ declare class MapboxService {
|
|
|
181
194
|
* existing entry when the id is already registered.
|
|
182
195
|
*/
|
|
183
196
|
addImage(id: string, img: HTMLImageElement | string): Promise<void>;
|
|
197
|
+
/**
|
|
198
|
+
* Register `image` under `id`, replacing any image already there. Unlike `addImage`'s in-place update, the size and
|
|
199
|
+
* the options (`pixelRatio`, `stretchX` / `stretchY`, `content`) may change, as a re-baked canvas sprite needs.
|
|
200
|
+
*/
|
|
201
|
+
replaceImage(id: string, image: MapImageSource, options?: MapImageOptions): void;
|
|
184
202
|
/** Flip a layer's `visibility` between `'visible'` and `'none'`. */
|
|
185
203
|
toggleLayerVisibility(layerId: string): void;
|
|
186
204
|
/**
|
|
@@ -219,6 +237,8 @@ declare class MapboxService {
|
|
|
219
237
|
private unlockInteractions;
|
|
220
238
|
/** Remove every polygon the user has drawn, keeping draw mode active. */
|
|
221
239
|
clearDrawnPolygons(): void;
|
|
240
|
+
/** `isStyleLoaded()` also waits for tiles; what addSource needs is mapbox's one-shot "style parsed" flag. */
|
|
241
|
+
private isStyleParsed;
|
|
222
242
|
/** Fetch a URL into an `HTMLImageElement`. Resolves on `load`, rejects on `error`. */
|
|
223
243
|
private loadImage;
|
|
224
244
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MapboxService, never>;
|
|
@@ -265,33 +285,12 @@ declare class ApexMapComponent {
|
|
|
265
285
|
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
286
|
}
|
|
267
287
|
|
|
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
288
|
type Coord = [number, number];
|
|
290
289
|
/**
|
|
291
290
|
* Recursively flatten any nesting of GeoJSON coordinates down to a flat list of [lng, lat] pairs.
|
|
292
291
|
* Handles Point, LineString, Polygon, and MultiPolygon coordinate shapes uniformly.
|
|
293
292
|
*/
|
|
294
|
-
declare function flattenCoords(arr:
|
|
293
|
+
declare function flattenCoords(arr: Position | Position[] | Position[][] | Position[][][]): Coord[];
|
|
295
294
|
/**
|
|
296
295
|
* Compute the [[minLng, minLat], [maxLng, maxLat]] bounds of a flat list of coordinates.
|
|
297
296
|
* Return value is compatible with `mapboxgl.LngLatBoundsLike`.
|
|
@@ -303,5 +302,5 @@ declare function calculateBounds(coords: Coord[]): mapboxgl.LngLatBoundsLike;
|
|
|
303
302
|
*/
|
|
304
303
|
declare function calculateViewportPolygonFromCenter(center: Coord, radiusKm?: number): number[][][];
|
|
305
304
|
|
|
306
|
-
export { ApexMapComponent,
|
|
307
|
-
export type {
|
|
305
|
+
export { ApexMapComponent, MapboxService, calculateBounds, calculateViewportPolygonFromCenter, flattenCoords };
|
|
306
|
+
export type { MapImageOptions, MapImageSource, MapInitOptions, SourceConfig };
|