@trackunit/react-map-adapter-shared 0.0.137 → 0.0.139

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/index.cjs.js CHANGED
@@ -816,6 +816,18 @@ const MAX_ZOOM = 22;
816
816
  * Amount to pan the map when using arrow keys (in pixels)
817
817
  */
818
818
  const KEYBOARD_PAN_AMOUNT = 100;
819
+ /**
820
+ * Minimum zoom level at which adapters render the traffic overlay.
821
+ *
822
+ * Google draws motorway traffic even at country/continent zoom (TrafficLayer
823
+ * has no zoom option), which reads as noise on a map full of markers and
824
+ * geofences. Below this zoom, adapters detach/hide traffic while the
825
+ * `showTraffic` preference stays untouched. Shared so every adapter applies
826
+ * the same threshold (Mapbox can pass it as a native layer `minzoom`).
827
+ *
828
+ * Not user-configurable by design; the value is a product/design decision.
829
+ */
830
+ const TRAFFIC_MIN_ZOOM = 7;
819
831
  /**
820
832
  * Amount to zoom when using +/- keys
821
833
  */
@@ -1820,12 +1832,17 @@ const mapAppearanceSchema = zod.z.object({
1820
1832
  theme: mapThemeSchema,
1821
1833
  mapType: mapTypeSchema,
1822
1834
  showRoads: zod.z.boolean(),
1835
+ // Optional so appearance literals written before traffic existed (including
1836
+ // external adapters built against an older contract) keep compiling and
1837
+ // validating; absent means false.
1838
+ showTraffic: zod.z.boolean().optional(),
1823
1839
  });
1824
1840
  /** Default appearance before any user preference is applied */
1825
1841
  const DEFAULT_MAP_APPEARANCE = {
1826
1842
  theme: "light",
1827
1843
  mapType: "roadmap",
1828
1844
  showRoads: false,
1845
+ showTraffic: false,
1829
1846
  };
1830
1847
  const INITIAL_CAMERA_STATE = {
1831
1848
  center: [0, 0],
@@ -2678,6 +2695,7 @@ exports.MAP_CURSORS = MAP_CURSORS;
2678
2695
  exports.MAX_ZOOM = MAX_ZOOM;
2679
2696
  exports.MIN_ZOOM = MIN_ZOOM;
2680
2697
  exports.SAFE_AREA_DEFAULT_BUFFER_PX = SAFE_AREA_DEFAULT_BUFFER_PX;
2698
+ exports.TRAFFIC_MIN_ZOOM = TRAFFIC_MIN_ZOOM;
2681
2699
  exports.WORLD_BBOX = WORLD_BBOX;
2682
2700
  exports.allocSafeAreaDebugId = allocSafeAreaDebugId;
2683
2701
  exports.anchorFromBottomCenter = anchorFromBottomCenter;
package/index.esm.js CHANGED
@@ -814,6 +814,18 @@ const MAX_ZOOM = 22;
814
814
  * Amount to pan the map when using arrow keys (in pixels)
815
815
  */
816
816
  const KEYBOARD_PAN_AMOUNT = 100;
817
+ /**
818
+ * Minimum zoom level at which adapters render the traffic overlay.
819
+ *
820
+ * Google draws motorway traffic even at country/continent zoom (TrafficLayer
821
+ * has no zoom option), which reads as noise on a map full of markers and
822
+ * geofences. Below this zoom, adapters detach/hide traffic while the
823
+ * `showTraffic` preference stays untouched. Shared so every adapter applies
824
+ * the same threshold (Mapbox can pass it as a native layer `minzoom`).
825
+ *
826
+ * Not user-configurable by design; the value is a product/design decision.
827
+ */
828
+ const TRAFFIC_MIN_ZOOM = 7;
817
829
  /**
818
830
  * Amount to zoom when using +/- keys
819
831
  */
@@ -1818,12 +1830,17 @@ const mapAppearanceSchema = z.object({
1818
1830
  theme: mapThemeSchema,
1819
1831
  mapType: mapTypeSchema,
1820
1832
  showRoads: z.boolean(),
1833
+ // Optional so appearance literals written before traffic existed (including
1834
+ // external adapters built against an older contract) keep compiling and
1835
+ // validating; absent means false.
1836
+ showTraffic: z.boolean().optional(),
1821
1837
  });
1822
1838
  /** Default appearance before any user preference is applied */
1823
1839
  const DEFAULT_MAP_APPEARANCE = {
1824
1840
  theme: "light",
1825
1841
  mapType: "roadmap",
1826
1842
  showRoads: false,
1843
+ showTraffic: false,
1827
1844
  };
1828
1845
  const INITIAL_CAMERA_STATE = {
1829
1846
  center: [0, 0],
@@ -2657,4 +2674,4 @@ const resolveStrokeColors = (style, shapeType, theme) => {
2657
2674
  };
2658
2675
  };
2659
2676
 
2660
- export { ANCHOR_SELECTOR, CIRCLE_SYMBOL_DEFAULT_DIAMETER_PX, CIRCLE_SYMBOL_DEFAULT_OPACITY, DEFAULT_CENTER, DEFAULT_MAP_APPEARANCE, DEFAULT_ZOOM, GEODESIC_MAX_SEGMENT_KM, HIT_SURFACE_SELECTOR, INITIAL_CAMERA_STATE, INITIAL_INTERACTION_STATE, INITIAL_MAP_STATE, INITIAL_MAP_STATUS, KEYBOARD_PAN_AMOUNT, KEYBOARD_ZOOM_AMOUNT, LAYER_FADE_DURATION_MS, MAP_CURSORS, MAX_ZOOM, MIN_ZOOM, SAFE_AREA_DEFAULT_BUFFER_PX, WORLD_BBOX, allocSafeAreaDebugId, anchorFromBottomCenter, angularDistance, attachSafeAreaHoverListeners, bboxEquals, bufferRectCorners, buildAdaptiveDomEntries, buildAdaptiveDomRenderFn, buildAdaptiveSymbolStyleFn, cameraStateEquals, canPatchAdaptiveMarker, canPatchAdaptiveViewport, canPatchMarkerInPlace, clearSafeArea, collectFeatureIdSet, computeInitialState, computeMarkerDomPortalZIndex, convexHull, createClusterPinElement, createDefaultClusterElement, createSymbolDotElement, defineAdapter, densifyGeodesicFeatures, disableSafeAreaDebug, discriminateRenderResult, enableSafeAreaDebug, estimateZoomFromBounds, extractLineCoordinates, extractPointCoordinates, extractPolygonPaths, extractSourceData, fadeInElement, filterRectsByCursorDirection, geometryTypeToShapeType, getAdaptiveDomFeatureIds, getAnchorRect, getEffectiveRestrictBounds, getHitSurfaceRect, googleMapCspDirectives, hasSameFeatureIds, intermediatePoint, isCanvasMarkerMode, isEventOfType, isSafeAreaDebugEnabled, mapAppearanceSchema, mapStateEquals, mapThemeSchema, mapTypeSchema, mapboxMapCspDirectives, mercatorCenterFromBounds, mergeAntimeridianFeatures, patchPortalDescriptors, pointInPolygon, removeGoneIndexedMarkers, renderSafeArea, resolveCircleSymbolDefaults, resolveHoveredStyle, resolveSelectedStyle, resolveStrokeColors, resolveSymbolDescriptor, safePolygon, toDeg, toRad, unwrapLongitudeNear, validateInitialViewport, watchSafeAreaLeave };
2677
+ export { ANCHOR_SELECTOR, CIRCLE_SYMBOL_DEFAULT_DIAMETER_PX, CIRCLE_SYMBOL_DEFAULT_OPACITY, DEFAULT_CENTER, DEFAULT_MAP_APPEARANCE, DEFAULT_ZOOM, GEODESIC_MAX_SEGMENT_KM, HIT_SURFACE_SELECTOR, INITIAL_CAMERA_STATE, INITIAL_INTERACTION_STATE, INITIAL_MAP_STATE, INITIAL_MAP_STATUS, KEYBOARD_PAN_AMOUNT, KEYBOARD_ZOOM_AMOUNT, LAYER_FADE_DURATION_MS, MAP_CURSORS, MAX_ZOOM, MIN_ZOOM, SAFE_AREA_DEFAULT_BUFFER_PX, TRAFFIC_MIN_ZOOM, WORLD_BBOX, allocSafeAreaDebugId, anchorFromBottomCenter, angularDistance, attachSafeAreaHoverListeners, bboxEquals, bufferRectCorners, buildAdaptiveDomEntries, buildAdaptiveDomRenderFn, buildAdaptiveSymbolStyleFn, cameraStateEquals, canPatchAdaptiveMarker, canPatchAdaptiveViewport, canPatchMarkerInPlace, clearSafeArea, collectFeatureIdSet, computeInitialState, computeMarkerDomPortalZIndex, convexHull, createClusterPinElement, createDefaultClusterElement, createSymbolDotElement, defineAdapter, densifyGeodesicFeatures, disableSafeAreaDebug, discriminateRenderResult, enableSafeAreaDebug, estimateZoomFromBounds, extractLineCoordinates, extractPointCoordinates, extractPolygonPaths, extractSourceData, fadeInElement, filterRectsByCursorDirection, geometryTypeToShapeType, getAdaptiveDomFeatureIds, getAnchorRect, getEffectiveRestrictBounds, getHitSurfaceRect, googleMapCspDirectives, hasSameFeatureIds, intermediatePoint, isCanvasMarkerMode, isEventOfType, isSafeAreaDebugEnabled, mapAppearanceSchema, mapStateEquals, mapThemeSchema, mapTypeSchema, mapboxMapCspDirectives, mercatorCenterFromBounds, mergeAntimeridianFeatures, patchPortalDescriptors, pointInPolygon, removeGoneIndexedMarkers, renderSafeArea, resolveCircleSymbolDefaults, resolveHoveredStyle, resolveSelectedStyle, resolveStrokeColors, resolveSymbolDescriptor, safePolygon, toDeg, toRad, unwrapLongitudeNear, validateInitialViewport, watchSafeAreaLeave };
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@trackunit/react-map-adapter-shared",
3
- "version": "0.0.137",
3
+ "version": "0.0.139",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
7
7
  "node": ">=24.x"
8
8
  },
9
9
  "dependencies": {
10
- "@trackunit/react-map-color-utils": "0.0.112",
11
- "@trackunit/geo-json-utils": "1.15.52",
12
- "@trackunit/ui-design-tokens": "1.15.40",
10
+ "@trackunit/react-map-color-utils": "0.0.114",
11
+ "@trackunit/geo-json-utils": "1.15.54",
12
+ "@trackunit/ui-design-tokens": "1.15.41",
13
13
  "es-toolkit": "^1.39.10",
14
14
  "zod": "^3.25.76"
15
15
  },
@@ -85,6 +85,16 @@ export type AdapterInstance<TConfig extends Record<string, unknown> = Record<str
85
85
  * Set whether road labels are shown over satellite/hybrid imagery
86
86
  */
87
87
  setShowRoads: (showRoads: boolean) => Promise<void>;
88
+ /**
89
+ * Set whether live traffic conditions are shown on the map.
90
+ *
91
+ * Optional capability: adapters that cannot render traffic leave this
92
+ * undefined (mirroring `layers: LayerPort | null`), and UI hides the
93
+ * traffic toggle. `showTraffic` records the preference; the adapter may
94
+ * still suppress rendering where the provider cannot draw traffic (plain
95
+ * satellite) or below TRAFFIC_MIN_ZOOM.
96
+ */
97
+ setShowTraffic?: (showTraffic: boolean) => Promise<void>;
88
98
  /**
89
99
  * Subscribe to map events
90
100
  */
@@ -29,6 +29,18 @@ export declare const MAX_ZOOM = 22;
29
29
  * Amount to pan the map when using arrow keys (in pixels)
30
30
  */
31
31
  export declare const KEYBOARD_PAN_AMOUNT = 100;
32
+ /**
33
+ * Minimum zoom level at which adapters render the traffic overlay.
34
+ *
35
+ * Google draws motorway traffic even at country/continent zoom (TrafficLayer
36
+ * has no zoom option), which reads as noise on a map full of markers and
37
+ * geofences. Below this zoom, adapters detach/hide traffic while the
38
+ * `showTraffic` preference stays untouched. Shared so every adapter applies
39
+ * the same threshold (Mapbox can pass it as a native layer `minzoom`).
40
+ *
41
+ * Not user-configurable by design; the value is a product/design decision.
42
+ */
43
+ export declare const TRAFFIC_MIN_ZOOM = 7;
32
44
  /**
33
45
  * Amount to zoom when using +/- keys
34
46
  */
@@ -19,19 +19,28 @@ export declare const mapAppearanceSchema: z.ZodObject<{
19
19
  theme: z.ZodEnum<["light", "dark"]>;
20
20
  mapType: z.ZodEnum<["roadmap", "satellite", "hybrid"]>;
21
21
  showRoads: z.ZodBoolean;
22
+ showTraffic: z.ZodOptional<z.ZodBoolean>;
22
23
  }, "strip", z.ZodTypeAny, {
23
24
  theme: "light" | "dark";
24
25
  mapType: "roadmap" | "satellite" | "hybrid";
25
26
  showRoads: boolean;
27
+ showTraffic?: boolean | undefined;
26
28
  }, {
27
29
  theme: "light" | "dark";
28
30
  mapType: "roadmap" | "satellite" | "hybrid";
29
31
  showRoads: boolean;
32
+ showTraffic?: boolean | undefined;
30
33
  }>;
31
34
  /**
32
- * Map appearance - grouped visual properties (theme, base layer, road overlay).
35
+ * Map appearance - grouped visual properties (theme, base layer, road and traffic overlays).
33
36
  * Nested inside MapState as `state.appearance` so it can be watched and
34
37
  * passed around as a single stable reference.
38
+ *
39
+ * `showTraffic` is the user's *preference*, not the rendered state: adapters
40
+ * without traffic support ignore it, and supporting adapters may suppress
41
+ * rendering (e.g. on plain satellite, or below TRAFFIC_MIN_ZOOM) while the
42
+ * preference stays true. It is optional (absent = false) so pre-traffic
43
+ * appearance literals keep compiling.
35
44
  */
36
45
  export type MapAppearance = Readonly<z.infer<typeof mapAppearanceSchema>>;
37
46
  /** Default appearance before any user preference is applied */