@apexara/map 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,6 +6,15 @@ A thin, opinionated Angular wrapper around [Mapbox GL JS](https://docs.mapbox.co
6
6
  - **Mapbox GL**: 3.x
7
7
  - **SSR-safe**: every browser-only call no-ops on the server.
8
8
 
9
+ Four entry points, so a page loads only what it uses:
10
+
11
+ | Import from | Holds | Loads |
12
+ | --- | --- | --- |
13
+ | `@apexara/map` | `<apex-map>`, `MapboxService`, `MapUserLocationLayer`, `apexMapPinchZoom`, the 1.0 utilities | Angular, mapbox-gl (~2 MB) |
14
+ | `@apexara/map/config` | `provideMap`, `MAP_CONFIG`, `MapStyles` | `@angular/core` only |
15
+ | `@apexara/map/search` | `MapboxSearchService` (address autocomplete) | Angular, no mapbox-gl |
16
+ | `@apexara/map/geo` | `MapGeometryUtil`, `MapColorUtil`, `MapSearchResponseUtil`, `MapStaticImageUtil`, `MapGeolocationUtil` | nothing: no Angular, no mapbox-gl |
17
+
9
18
  ---
10
19
 
11
20
  ## Table of contents
@@ -26,11 +35,18 @@ A thin, opinionated Angular wrapper around [Mapbox GL JS](https://docs.mapbox.co
26
35
  - [Events](#events)
27
36
  - [Images & icons](#images--icons)
28
37
  - [Teardown](#teardown)
38
+ - [Polygon draw](#polygon-draw)
39
+ - [User location](#user-location)
40
+ - [Pinch zoom over overlays](#pinch-zoom-over-overlays)
29
41
  - [Utilities](#utilities)
42
+ - [Geometry: `@apexara/map/geo`](#geometry-apexaramapgeo)
43
+ - [Address search: `@apexara/map/search`](#address-search-apexaramapsearch)
44
+ - [Static images](#static-images)
30
45
  - [Types & tokens](#types--tokens)
31
46
  - [Recipes](#recipes)
32
47
  - [SSR notes](#ssr-notes)
33
48
  - [Troubleshooting](#troubleshooting)
49
+ - [Changes since v1.1.1](#changes-since-v111)
34
50
 
35
51
  ---
36
52
 
@@ -234,9 +250,35 @@ async addMyLayers(): Promise<void> {
234
250
  - `getCenter()` / `getZoom()` — imperative reads; prefer the signals.
235
251
  - `getViewportPolygon()` — the current viewport as a closed GeoJSON ring (`[sw, se, ne, nw, sw]`).
236
252
  - `moveCenter([lng, lat], zoom = 13)` — animated `flyTo`.
237
- - `fitBounds(bounds, padding = 40)` — animated `fitBounds`.
253
+ - `fitBounds(bounds, options?, eventData?)` — animated `fitBounds`. A number is the padding (default 40) of a one-second
254
+ slide, as in 1.0. An options object (`padding` as a number or per side, `maxZoom`, `duration`, `animate: false`, …)
255
+ lays over those same defaults.
256
+ - `flyTo(options, eventData?)`, `easeTo(options, eventData?)`, `jumpTo(options, eventData?)` — mapbox's camera calls
257
+ with every option (`duration`, `curve`, `offset`, …).
258
+ - `resize(eventData?)` — have mapbox re-read its container's size, e.g. from a `ResizeObserver`. The resize fires
259
+ `movestart` / `moveend`, which carry `eventData`. A no-op before the map exists.
238
260
  - `project(lngLat)` — geographic → pixel coordinates.
239
- - `setStyle(styleUrl)` — swap the base style. **Re-apply your custom sources/layers after `styledata` — Mapbox drops them during the swap.**
261
+ - `isPointOnScreen(lngLat, insets = 0)` — whether the point projects inside the canvas, `insets` pixels in from its
262
+ edges (one number, or `{ top, right, bottom, left }`, a side left out being 0). `false` before the map exists.
263
+ - `setStyle(styleUrl, options?)` — swap the base style. `{ diff: false }` rebuilds the style from scratch: use it when
264
+ mapbox's diff keeps one of your sources and the rebuild then throws on it. **Re-apply your custom sources/layers after
265
+ `styledata` — Mapbox drops them during the swap.**
266
+
267
+ `eventData` is copied by mapbox onto the move's `movestart` / `moveend`, which is how a listener tells the app's own
268
+ moves from the reader's:
269
+
270
+ ```ts
271
+ const PROGRAMMATIC_MOVE = { programmaticMove: true };
272
+
273
+ map.fitBounds(bounds, { padding: 60, maxZoom: 15, animate: false }, PROGRAMMATIC_MOVE);
274
+ map.flyTo({ center: [-80.84, 35.22], zoom: 14, duration: 900, curve: 1.2 }, PROGRAMMATIC_MOVE);
275
+ map.on('moveend', (event: { programmaticMove?: boolean }) => {
276
+ if (!event.programmaticMove) { /* the reader moved the map */ }
277
+ });
278
+ ```
279
+
280
+ The map is shared: `activeContainer()` is the container showing it now, and `isShownIn(element)` says whether that is
281
+ `element` or something inside it. A consumer whose container is not the active one should leave the camera alone.
240
282
 
241
283
  ### Sources
242
284
 
@@ -256,6 +298,17 @@ map.removeSource('stops');
256
298
  map.hasSource('stops'); // boolean
257
299
  ```
258
300
 
301
+ `data` takes any GeoJSON (a collection, a single `Feature`, a geometry) or a URL.
302
+
303
+ `upsertSource(config)` adds the source, or replaces the data of the one already under `config.id` in place (its other
304
+ options stay). It returns `true` when it added it, so the caller adds the layers that draw it only once:
305
+
306
+ ```ts
307
+ if (map.upsertSource({ id: 'drawn', data: collection })) {
308
+ map.addLayer({ id: 'drawn-fill', type: 'fill', source: 'drawn', paint: { 'fill-opacity': 0.12 } });
309
+ }
310
+ ```
311
+
259
312
  ### Layers
260
313
 
261
314
  ```ts
@@ -278,8 +331,12 @@ map.toggleLayerVisibility('tiles');
278
331
  map.getLayerIds(); // all layer ids in the current style
279
332
  map.hasLayer('stops-circles');
280
333
  map.safeRemoveLayer('stops-circles');
334
+ map.moveLayer('stops-circles'); // to the top
335
+ map.moveLayer('stops-circles', 'road-label'); // just under another layer
281
336
  ```
282
337
 
338
+ `moveLayer` no-ops when the layer is missing.
339
+
283
340
  ### Filters, paint, layout
284
341
 
285
342
  ```ts
@@ -326,6 +383,14 @@ map.on('click', 'clusters', async (e: mapboxgl.MapMouseEvent) => {
326
383
 
327
384
  `getClusterProperties(sourceId, clusterId, limit = 10000, offset = 0)` rejects if the source is missing or not clustered.
328
385
 
386
+ `getClusterExpansionZoom(sourceId, clusterId)` resolves the zoom at which the cluster splits, to ease into it. It rejects
387
+ the same way, and when mapbox answers with no zoom:
388
+
389
+ ```ts
390
+ const zoom = await map.getClusterExpansionZoom('stops', props.cluster_id);
391
+ map.easeTo({ center: clusterCenter, zoom });
392
+ ```
393
+
329
394
  ### Events
330
395
 
331
396
  `on` supports both the raw two-arg form and the layer-scoped three-arg form:
@@ -336,7 +401,12 @@ map.on('mouseenter', 'stops-circles', () => { /* ... */ });
336
401
  map.off('click', 'stops-circles', handler);
337
402
  ```
338
403
 
339
- `getRenderedFeatures(point, { layers })` queries what's drawn under a screen point.
404
+ `getRenderedFeatures(geometry?, { layers, filter })` queries what's drawn under a screen point, inside a
405
+ `[corner, corner]` box, or across the whole viewport when `geometry` is `undefined`; `filter` is a mapbox expression:
406
+
407
+ ```ts
408
+ const stillShown = map.getRenderedFeatures(undefined, { layers: ['pins'], filter: ['==', ['get', 'id'], selectedId] });
409
+ ```
340
410
 
341
411
  `getFeatureProperties<T>(event)` is a convenience to pull typed `properties` off the first feature in an event.
342
412
 
@@ -366,6 +436,67 @@ map.replaceImage('price-pill', pixels, {
366
436
  (`pixelRatio`, `sdf`, `stretchX` / `stretchY`, `content`). Re-register after a `setStyle` that replaces the style: the
367
437
  runtime images go with it.
368
438
 
439
+ ### Polygon draw
440
+
441
+ `enableDrawPolygon(options?)` mounts `@mapbox/mapbox-gl-draw` (no UI of its own) in `draw_polygon` mode and locks the
442
+ map's gestures so the view holds still. The reader clicks corners and double-clicks (or clicks the first corner) to
443
+ close the shape, which arrives on `polygonCreate`.
444
+
445
+ - `{ keepPanZoom: true }` leaves drag, wheel and pinch zoom on (a click still adds a corner on a moving map, and a map
446
+ that will not pan reads as broken); box zoom, double-click zoom (it closes the shape) and keyboard stay locked.
447
+ - `finishDrawPolygon()` closes the shape in progress, as a double-click would, e.g. from a "Done" button. It arrives on
448
+ `polygonCreate` when it has three corners or more. Draw mode stays until `disableDrawPolygon()`.
449
+ - `disableDrawPolygon()` removes the control and every drawn shape and gives the gestures back as they were.
450
+ - `clearDrawnPolygons()` removes the drawn shapes and stays in draw mode.
451
+
452
+ ```ts
453
+ map.polygonCreate.subscribe((polygon) => this.scope.set(polygon));
454
+ map.enableDrawPolygon({ keepPanZoom: true });
455
+ // "Done" button:
456
+ map.finishDrawPolygon();
457
+ ```
458
+
459
+ ### User location
460
+
461
+ `MapUserLocationLayer` puts the reader's location on the map as a dot and flies to it. It is not injectable: a map
462
+ surface builds one with its `MapboxService`. The dot's look and the zoom it flies to are the consumer's: `style` and
463
+ `zoom` are required and have no default.
464
+
465
+ ```ts
466
+ import { MapUserLocationLayer } from '@apexara/map';
467
+
468
+ const me = new MapUserLocationLayer(map, {
469
+ zoom: 14,
470
+ style: { circleRadius: 8, circleColor: '#1f6feb', strokeColor: '#ffffff', strokeWidth: 3 },
471
+ });
472
+
473
+ await me.init(); // one read of the location, draws the dot; the camera stays
474
+ await me.locate(); // flies to it, reading it first when none is known yet
475
+ me.repaint(); // after a style swap
476
+ me.destroy(); // on teardown; the location is kept
477
+ ```
478
+
479
+ `init` and `locate` resolve to a `MapLocateResult` (`located` with `position`, `denied`, or `unavailable`) and never
480
+ reject. `location` is a signal of the last `[lng, lat]` read. Options: `style` (`circleRadius`, `circleColor`,
481
+ `strokeColor`, `strokeWidth`, all required), `zoom` (required), `sourceId` (`'user-location'`) and `layerId`
482
+ (`'user-location-dot'`).
483
+
484
+ ### Pinch zoom over overlays
485
+
486
+ A trackpad pinch arrives as ctrl+wheel. Over anything laid on the map (a card, the map's buttons, a legend) it zooms the
487
+ whole page. `apexMapPinchZoom` hands it to the map under it instead, the same as a pinch over the map itself:
488
+
489
+ ```html
490
+ <div class="map-page" apexMapPinchZoom>
491
+ <apex-map />
492
+ <aside class="legend">…</aside>
493
+ </div>
494
+ ```
495
+
496
+ Put it on the overlay itself or on a container holding the map and its overlays. It acts only while the shared map is
497
+ shown inside that element (or inside the element an anchored card is positioned in), only over the map's own box, and
498
+ only while the map's wheel zoom is on.
499
+
369
500
  ### Teardown
370
501
 
371
502
  The shared map is never destroyed. `deactivate(container)` takes it off `container`: it moves back to the container
@@ -394,11 +525,125 @@ const ring = calculateViewportPolygonFromCenter([-80.84, 35.22], 0.5);
394
525
 
395
526
  - `flattenCoords(arr)` — flatten any GeoJSON coordinate nesting into `[lng, lat][]`. Takes a geometry's
396
527
  `coordinates` as they are (`Position`, `Position[]`, `Position[][]`, `Position[][][]`), no cast needed.
397
- - `calculateBounds(coords)` — `[[minLng, minLat], [maxLng, maxLat]]`, compatible with `LngLatBoundsLike`.
528
+ - `calculateBounds(coords, options?)` — `[[minLng, minLat], [maxLng, maxLat]]`, compatible with `LngLatBoundsLike`.
529
+ `{ wrapAntimeridian: true }` frames a shape across ±180° by its narrower side (see `MapGeometryUtil.boundsOf`).
398
530
  - `calculateViewportPolygonFromCenter(center, radiusKm = 0.5)` — a closed square ring around `center`.
399
531
 
400
532
  ---
401
533
 
534
+ ## Geometry: `@apexara/map/geo`
535
+
536
+ `MapGeometryUtil` is plain math with no runtime imports, so a server, a list page without a map or a worker can use it.
537
+ Every point is `[lng, lat]`.
538
+
539
+ ```ts
540
+ import { MapGeometryUtil } from '@apexara/map/geo';
541
+
542
+ MapGeometryUtil.milesBetween([-80.84, 35.22], [-78.64, 35.78], 2); // 129.66: haversine, rounded when decimals are given
543
+ MapGeometryUtil.hasLocation(lng, lat); // finite, and not the 0, 0 of a missing location
544
+ MapGeometryUtil.boundsAround(center, 2 * MapGeometryUtil.METRES_PER_MILE); // [[w, s], [e, n]] reaching that far
545
+ MapGeometryUtil.circleRing(center, 1609.344); // closed 64-segment ring, for a GeoJSON Polygon
546
+ MapGeometryUtil.cameraForBounds(bounds, frame.getBoundingClientRect(), 40); // { center, zoom } | null, no map needed
547
+ MapGeometryUtil.boundsOf(featureCollection, { wrapAntimeridian: true }); // [[w, s], [e, n]] | null
548
+ MapGeometryUtil.containsBounds(outer, inner, 0.001); // outer covers inner, forgiving 0.1% of its span
549
+ MapGeometryUtil.sameOuterRing(previous, next); // same outer ring, point for point
550
+ ```
551
+
552
+ - `boundsOf(geoJson, options?)` takes any GeoJSON (a collection, a feature, a geometry, a geometry collection) and walks
553
+ its positions in place, with no flat copy: a state's hundreds of thousands of points cost no allocation. Features with
554
+ no geometry are skipped; no position at all gives `null`. With `wrapAntimeridian` it also measures longitudes on
555
+ 0–360 and keeps the narrower span, so the Aleutians frame as `[[172, 51], [190, 53]]` rather than the whole planet
556
+ (mapbox wraps an east past 180 itself).
557
+ - `cameraForBounds(bounds, size, padding = 0, maxZoom = 22)` — the Web Mercator centre and zoom fitting a box in a
558
+ frame before any map exists (mapbox's own needs one), e.g. for `MapInitOptions`. `null` when the padding leaves no
559
+ room; a box with no area stops at `maxZoom`.
560
+ - `boundsAround` and `circleRing` measure a degree as 111,320 m, with longitude narrowing by the cosine of the latitude,
561
+ so a circle and the box framing it always agree.
562
+ - `forEachPosition(coordinates, visit)` — calls `visit` with every position at any nesting, as the arrays they are
563
+ (`flattenCoords` is built on it).
564
+ - `containsBounds(outer, inner, tolerance = 0)` — whether `outer` covers all of `inner`, edges included. `tolerance`
565
+ forgives a miss up to that share of `inner`'s span per axis, for a box framed to the other's edge where rounding can
566
+ leave it a hair short.
567
+ - `sameOuterRing(first, second)` — whether two polygons' outer rings match point for point (holes are not compared; two
568
+ `null`s match). Use it as the `equal` of a signal holding `getViewportPolygon()`, so an unmoved camera is no change:
569
+
570
+ ```ts
571
+ const viewport = signal<Position[][] | null>(null, { equal: (first, second) => MapGeometryUtil.sameOuterRing(first, second) });
572
+ ```
573
+
574
+ `MapColorUtil.toMapboxColor(cssColor)` turns `#rrggbbaa` and `#rgba`, which mapbox's style parser rejects, into
575
+ `rgba(r, g, b, a)` with the alpha to three places, and leaves any other value as it is. Use it on a paint colour read from
576
+ a CSS custom property:
577
+
578
+ ```ts
579
+ const fill = MapColorUtil.toMapboxColor(getComputedStyle(document.documentElement).getPropertyValue('--area-fill').trim());
580
+ ```
581
+
582
+ `MapGeolocationUtil.locate(options?)` is one read of the browser's location as a promise that always resolves:
583
+ `{ status: 'located', position: [lng, lat] }`, `{ status: 'denied' }` (the reader refused) or
584
+ `{ status: 'unavailable' }` (no geolocation, a timeout, an error). `options` are the browser's `maximumAge`, `timeout`
585
+ and `enableHighAccuracy`.
586
+
587
+ ---
588
+
589
+ ## Address search: `@apexara/map/search`
590
+
591
+ `MapboxSearchService` is address autocomplete over the Mapbox Search Box API, with the token from `provideMap`. It does
592
+ not load mapbox-gl, so an address field costs no map.
593
+
594
+ ```ts
595
+ import { MapboxSearchService } from '@apexara/map/search';
596
+
597
+ private readonly search = inject(MapboxSearchService);
598
+
599
+ const suggestions = await this.search.suggest(term, { types: 'address', country: 'us', limit: 6 });
600
+ const place = await this.search.retrieve(suggestions[0].mapboxId); // the only call with lat / lon
601
+ ```
602
+
603
+ - The filters are the app's choice: `types`, `country` and `limit` are sent only when given, and each one left out
604
+ takes Mapbox's default. The package sets none.
605
+ - Billed per session: `suggest` calls share one session token until a `retrieve` ends it, and the next `suggest` starts
606
+ a new one. Retrieve on a pick, not on every keystroke.
607
+ - A `MapSearchResult` is `{ mapboxId, name, fullAddress, city, region, postcode, lat, lon }`: `name` is the street line
608
+ for an address, `region` and `postcode` carry Mapbox's own names (`region` is its `region_code`, e.g. `NC`), and
609
+ `lat` / `lon` are `null` on a suggestion. A field Mapbox did not send is `''`.
610
+ - Quiet on failure: an error status, a network error or the 5-second timeout give `[]` / `null`. `isAvailable` is
611
+ `false` with no token or on the server, and then nothing is requested.
612
+ - It calls `fetch`, never `HttpClient`, so an app's interceptors cannot send its own credentials to api.mapbox.com.
613
+
614
+ `MapSearchResponseUtil` (in `@apexara/map/geo`) is the parser it uses, for code that calls Mapbox itself:
615
+ `localityOf(context)` reads `city`, `region` and `postcode` from a `context` (Search Box and Geocoding v6 share the
616
+ shape), `resultOf(suggestion)` and `placeOf(mapboxId, feature)` build results.
617
+
618
+ ---
619
+
620
+ ## Static images
621
+
622
+ `MapStaticImageUtil.url(options)` (in `@apexara/map/geo`) builds a Mapbox Static Images URL: a style rendered as one
623
+ still, e.g. a placeholder while the live map is held back.
624
+
625
+ ```ts
626
+ import { MapStaticImageUtil } from '@apexara/map/geo';
627
+ import { MapStyles } from '@apexara/map/config';
628
+
629
+ const still = MapStaticImageUtil.url({
630
+ accessToken: environment.mapboxToken,
631
+ style: MapStyles.LightV11,
632
+ center: [-80.84, 35.22],
633
+ zoom: 11,
634
+ width: 800,
635
+ height: 600,
636
+ retina: true,
637
+ attribution: false,
638
+ logo: false,
639
+ });
640
+ ```
641
+
642
+ `style` is a hosted style (`mapbox://styles/<owner>/<id>` or `<owner>/<id>`). Options left out take mapbox's defaults
643
+ (bearing and pitch 0, attribution and logo shown); width and height go up to 1280.
644
+
645
+ ---
646
+
402
647
  ## Types & tokens
403
648
 
404
649
  ```ts
@@ -412,18 +657,45 @@ import {
412
657
 
413
658
  // The map itself (loads mapbox-gl).
414
659
  import {
660
+ type MapDrawOptions,
661
+ type MapEventData,
662
+ type MapFeatureQuery,
663
+ type MapFitOptions,
415
664
  type MapImageOptions,
416
665
  type MapImageSource,
417
666
  type MapInitOptions,
667
+ type MapInsets,
668
+ type MapQueryGeometry,
669
+ type MapStyleOptions,
670
+ type MapUserLocationConfig,
671
+ type MapUserLocationStyle,
418
672
  type SourceConfig,
419
673
  } from '@apexara/map';
674
+
675
+ // No runtime imports.
676
+ import {
677
+ type MapBounds,
678
+ type MapBoundsOptions,
679
+ type MapCamera,
680
+ type MapLngLat,
681
+ type MapLocateResult,
682
+ type MapSearchResult,
683
+ type MapStaticImageOptions,
684
+ } from '@apexara/map/geo';
420
685
  ```
421
686
 
422
687
  `@apexara/map` re-exports everything `@apexara/map/config` holds (one token, not a copy), so 1.0.0 imports keep working.
423
688
 
424
689
  - `MapStyles` — enum of common Mapbox-hosted styles (`Streets`, `Sat`, `DarkV11`, `LightV11`, `OutdoorsV12`).
425
690
  - `MapInitOptions` — shape accepted by `MapboxService.init` (the component builds this for you).
426
- - `SourceConfig` — shape accepted by `addSource` (GeoJSON + clustering flags).
691
+ - `SourceConfig` — shape accepted by `addSource` / `upsertSource` (any GeoJSON or a URL, + clustering flags).
692
+ - `MapFitOptions` — `fitBounds` options (mapbox's `EasingOptions`); `MapEventData` — what camera calls pass on to the
693
+ move's events.
694
+ - `MapQueryGeometry` / `MapFeatureQuery` — what `getRenderedFeatures` takes; `MapInsets` — `isPointOnScreen`'s insets.
695
+ - `MapStyleOptions` (`diff`), `MapDrawOptions` (`keepPanZoom`), `MapUserLocationConfig` / `MapUserLocationStyle` (the
696
+ dot's look, required).
697
+ - `MapLngLat` (`[lng, lat]`), `MapBounds` (`[[w, s], [e, n]]`), `MapCamera`, `MapLocateResult`, `MapSearchResult`,
698
+ `MapStaticImageOptions` — from `@apexara/map/geo`.
427
699
  - `MapImageSource` / `MapImageOptions` — what `replaceImage` accepts (the image and `addImage`'s options).
428
700
  - `MapConfig` / `MAP_CONFIG` — root-level token, usually set via `provideMap`.
429
701
 
@@ -491,6 +763,32 @@ map.setStyle(MapStyles.DarkV11);
491
763
  - **Sources/layers disappear after `setStyle`** — Mapbox replaces the entire style. Re-add them in a `styledata` listener.
492
764
  - **`setFeatureState` does nothing** — the source was added without `generateId: true` and features have no numeric `id`.
493
765
  - **Cluster expand rejects** — the `sourceId` either doesn't exist or was added without `clustered: true`.
766
+ - **`setStyle` throws "There is already a source with ID …"** — mapbox's diff kept a source your rebuild adds again.
767
+ Pass `{ diff: false }`.
768
+
769
+ ---
770
+
771
+ ## Changes since v1.1.1
772
+
773
+ Additions only; every 1.1.1 call works as before.
774
+
775
+ - **Two new entry points.** `@apexara/map/geo` (no runtime imports): `MapGeometryUtil`, `MapColorUtil`,
776
+ `MapSearchResponseUtil`, `MapStaticImageUtil`, `MapGeolocationUtil`, `MapApiConfig` and their types.
777
+ `@apexara/map/search` (no mapbox-gl): `MapboxSearchService`, whose `suggest` filters are the app's to pass. A
778
+ `MapSearchResult` names its parts as Mapbox does: `city`, `region`, `postcode`.
779
+ - **Camera.** `fitBounds` also takes an options object and event data; new `flyTo`, `easeTo`, `jumpTo` and
780
+ `resize` with event data; `isPointOnScreen(lngLat, insets?)`; `isShownIn(element)`.
781
+ - **Clusters.** `getClusterExpansionZoom(sourceId, clusterId)`.
782
+ - **Style.** `setStyle(styleUrl, { diff })`.
783
+ - **Sources and layers.** `upsertSource(config)`; `SourceConfig.data` and `updateSource` take any GeoJSON;
784
+ `moveLayer(id, beforeId?)`; `getRenderedFeatures` takes a box, no geometry (the whole viewport) and a `filter`.
785
+ - **Polygon draw.** `enableDrawPolygon({ keepPanZoom })` and `finishDrawPolygon()`.
786
+ - **Bounds.** `calculateBounds(coords, { wrapAntimeridian })`. `calculateBounds` and `flattenCoords` now run on
787
+ `MapGeometryUtil`; their answers for valid coordinates are unchanged. `MapGeometryUtil.containsBounds` and
788
+ `sameOuterRing` compare boxes and rings.
789
+ - **Colours.** `MapColorUtil.toMapboxColor` turns the hex forms mapbox rejects (`#rrggbbaa`, `#rgba`) into `rgba(...)`.
790
+ - **New pieces.** `MapUserLocationLayer` (the location dot, in the app's own `style`, and the fly to it at the app's
791
+ own `zoom`) and the `apexMapPinchZoom` directive.
494
792
 
495
793
  ---
496
794