@rio-cloud/rio-uikit 2.3.0 → 2.4.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.
Files changed (76) hide show
  1. package/MapPreviousViewportButton.d.ts +2 -0
  2. package/MapPreviousViewportButton.js +5 -0
  3. package/MapPreviousViewportButton.js.map +1 -0
  4. package/Table.js +15 -14
  5. package/TableNext.js +15 -14
  6. package/components/map/components/Map.js +175 -157
  7. package/components/map/components/Map.js.map +1 -1
  8. package/components/map/components/MapContext.d.ts +2 -0
  9. package/components/map/components/MapContext.js +8 -6
  10. package/components/map/components/MapContext.js.map +1 -1
  11. package/components/map/components/MapPosition.d.ts +1 -1
  12. package/components/map/components/MapPosition.js +20 -13
  13. package/components/map/components/MapPosition.js.map +1 -1
  14. package/components/map/components/features/MapZoom.d.ts +0 -1
  15. package/components/map/components/features/MapZoom.js +12 -20
  16. package/components/map/components/features/MapZoom.js.map +1 -1
  17. package/components/map/components/features/layers/overlayLayers/IncidentsLayer.d.ts +1 -0
  18. package/components/map/components/features/layers/overlayLayers/IncidentsLayer.js +64 -62
  19. package/components/map/components/features/layers/overlayLayers/IncidentsLayer.js.map +1 -1
  20. package/components/map/components/features/layers/overlayLayers/TrafficLayer.js +1 -1
  21. package/components/map/components/features/layers/overlayLayers/TrafficLayer.js.map +1 -1
  22. package/components/map/components/features/settings/MapSettingsTile.d.ts +27 -0
  23. package/components/map/components/features/settings/MapSettingsTile.js +17 -17
  24. package/components/map/components/features/settings/MapSettingsTile.js.map +1 -1
  25. package/components/map/components/features/settings/buttons/MapPreviousViewportButton.d.ts +10 -0
  26. package/components/map/components/features/settings/buttons/MapPreviousViewportButton.js +23 -0
  27. package/components/map/components/features/settings/buttons/MapPreviousViewportButton.js.map +1 -0
  28. package/components/map/hooks/useMapViewportHistory.d.ts +19 -0
  29. package/components/map/hooks/useMapViewportHistory.js +116 -0
  30. package/components/map/hooks/useMapViewportHistory.js.map +1 -0
  31. package/components/map/icons/MapIcon.d.ts +1 -0
  32. package/components/map/icons/MapIcon.js +46 -37
  33. package/components/map/icons/MapIcon.js.map +1 -1
  34. package/components/map/utils/mapTypes.d.ts +6 -0
  35. package/components/map/utils/mapTypes.js.map +1 -1
  36. package/components/selects/BaseSelectDropdown.js +72 -76
  37. package/components/selects/BaseSelectDropdown.js.map +1 -1
  38. package/components/selects/Multiselect.d.ts +6 -0
  39. package/components/selects/Multiselect.js +131 -125
  40. package/components/selects/Multiselect.js.map +1 -1
  41. package/components/selects/Select.d.ts +6 -0
  42. package/components/selects/Select.js +79 -71
  43. package/components/selects/Select.js.map +1 -1
  44. package/components/table/Table.d.ts +2 -0
  45. package/components/table/Table.js +162 -158
  46. package/components/table/Table.js.map +1 -1
  47. package/components/table/Table.types.d.ts +6 -0
  48. package/components/table/TableExpandAllGroupsButton.d.ts +25 -0
  49. package/components/table/TableExpandAllGroupsButton.js +27 -0
  50. package/components/table/TableExpandAllGroupsButton.js.map +1 -0
  51. package/components/table/TableExpandedRow.js +77 -63
  52. package/components/table/TableExpandedRow.js.map +1 -1
  53. package/components/table/TableExpanderButton.js +11 -11
  54. package/components/table/TableExpanderButton.js.map +1 -1
  55. package/components/table/TableGroupRow.d.ts +13 -1
  56. package/components/table/TableGroupRow.js +57 -23
  57. package/components/table/TableGroupRow.js.map +1 -1
  58. package/components/table/TableHeader.js +40 -39
  59. package/components/table/TableHeader.js.map +1 -1
  60. package/components/table/TableRow.js +66 -52
  61. package/components/table/TableRow.js.map +1 -1
  62. package/components/table/context/TableRenderConfigContext.d.ts +2 -1
  63. package/components/table/context/TableRenderConfigContext.js.map +1 -1
  64. package/components/table/render/header/TableHeaderCellContent.js +4 -4
  65. package/components/table/render/header/TableHeaderCellContent.js.map +1 -1
  66. package/components/table/render/header/TableHeaderSelectionCell.d.ts +2 -0
  67. package/components/table/render/header/TableHeaderSelectionCell.js +22 -12
  68. package/components/table/render/header/TableHeaderSelectionCell.js.map +1 -1
  69. package/components/table/runtime/useRenderDraftState.js +1 -0
  70. package/components/table/runtime/useRenderDraftState.js.map +1 -1
  71. package/components/table/selection/useInternalTableSelectionState.js +12 -10
  72. package/components/table/selection/useInternalTableSelectionState.js.map +1 -1
  73. package/package.json +1 -1
  74. package/version.d.ts +1 -1
  75. package/version.js +1 -1
  76. package/version.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Map.js","sources":["../../../../src/components/map/components/Map.tsx"],"sourcesContent":["import { useRef, useState, useEffect, type CSSProperties } from 'react';\nimport { isEmpty } from 'es-toolkit/compat';\nimport { isEqual } from 'es-toolkit/predicate';\n\nimport {\n MAP_TYPE_DEFAULT,\n MAP_TYPE_FLEET_STYLE,\n MAP_TYPE_SATELLITE,\n MAP_TYPE_TERRAIN,\n MAP_TYPE_NIGHT,\n MAP_LAYER_INCIDENTS,\n MAP_LAYER_TRAFFIC,\n MAP_LAYER_ROAD_RESTRICTIONS,\n DEFAULT_MIN_ZOOM,\n DEFAULT_MAX_ZOOM,\n DEFAULT_PIXEL_RATIO,\n} from './constants';\n\nimport { addEventListenerMap, removeEventListenerMap } from '../utils/eventHandling';\nimport { MapContext } from './MapContext';\nimport { createUtils, getMapBounds } from '../utils/mapUtils';\nimport { getHereUi } from '../utils/mapUi';\nimport useDarkMode from '../../../hooks/useDarkMode';\nimport MapZoom from './features/MapZoom';\nimport MapOverlayLayers from './features/layers/MapOverlayLayers';\nimport MapSize from './MapSize';\nimport MapPosition from './MapPosition';\nimport MapElements from './MapElements';\nimport type { MapApi, MapLayer, MapProps, MapType } from '../utils/mapTypes';\nimport { getPlatform, getEngineType, getBaseLayer } from '../utils/rendering';\n\nconst MARKER_POINTER_EVENTS_DISABLED_CLASS = 'map-disable-marker-pointer-events';\nconst MARKER_POINTER_EVENTS_RESET_DELAY_MS = 140;\n\nconst Map = (props: MapProps) => {\n const {\n children,\n credentials,\n width,\n height,\n language: lang = 'en',\n center,\n zoom,\n zoomAnimation = false,\n boundingBox,\n hideClusterSettings = false,\n hideMapLayerSettings = false,\n disableMapEvents,\n disableBehavior = false,\n disableZoomMomentum = true,\n enableFractionalZoom = false,\n eventListenerMap,\n mapType = MAP_TYPE_DEFAULT,\n mapLayer = [],\n showCluster: externalShowCluster = true,\n showScaleBar = false,\n onMapLayerChange = () => {},\n onMapTypeChange = () => {},\n onShowClusterChange = () => {},\n onZoomIn = () => {},\n onZoomOut = () => {},\n onIncidentsChange = () => {},\n mapSettingsTooltip,\n mapSettings,\n enableWebGL = true,\n enableDevicePixelRatio = true,\n enableMarkerIconCache = true,\n disableMarkerPointerEventsWhileZooming = false,\n pixelRatio = DEFAULT_PIXEL_RATIO,\n minZoom = DEFAULT_MIN_ZOOM,\n maxZoom = DEFAULT_MAX_ZOOM,\n } = props;\n\n let safeMaxZoom = maxZoom;\n\n if (minZoom > maxZoom) {\n // Avoid crashing the map for invalid zoom limits\n safeMaxZoom = DEFAULT_MAX_ZOOM;\n console.error('Invalid condition for zoom limits: min <= max)');\n }\n\n const mapRef = useRef<HTMLDivElement>(null);\n const markerPointerEventsResetTimeoutRef = useRef<number | undefined>();\n const markerPointerEventsDisabledRef = useRef(false);\n const disableMarkerPointerEventsWhileZoomingRef = useRef(disableMarkerPointerEventsWhileZooming);\n\n const [isMapInitialized, setMapInitialized] = useState(false);\n const [isZoomInteractionActive, setIsZoomInteractionActive] = useState(false);\n\n const [api, setApi] = useState<MapApi>();\n\n const [baseLayer, setBaseLayer] = useState<MapType>(mapType);\n const [activeLayers, setActiveLayers] = useState<MapLayer[]>(mapLayer);\n const [showCluster, setShowCluster] = useState(externalShowCluster);\n\n const devicePixelRatio = enableDevicePixelRatio ? window.devicePixelRatio || pixelRatio : pixelRatio;\n\n // Only short locale is supported by HERE Map\n const language = (locale => (locale === 'nb' ? 'no' : locale))(lang.split('-')[0].toLowerCase());\n\n const setMarkerPointerEventsDisabled = (disabled: boolean) => {\n if (disabled && !disableMarkerPointerEventsWhileZoomingRef.current) {\n return;\n }\n\n const mapElement = mapRef.current;\n\n if (!mapElement) {\n return;\n }\n\n mapElement.classList.toggle(MARKER_POINTER_EVENTS_DISABLED_CLASS, disabled);\n markerPointerEventsDisabledRef.current = disabled;\n };\n\n const clearMarkerPointerEventsResetTimeout = () => {\n if (markerPointerEventsResetTimeoutRef.current !== undefined) {\n window.clearTimeout(markerPointerEventsResetTimeoutRef.current);\n markerPointerEventsResetTimeoutRef.current = undefined;\n }\n };\n\n const scheduleMarkerPointerEventsEnable = () => {\n clearMarkerPointerEventsResetTimeout();\n markerPointerEventsResetTimeoutRef.current = window.setTimeout(() => {\n setMarkerPointerEventsDisabled(false);\n setIsZoomInteractionActive(false);\n markerPointerEventsResetTimeoutRef.current = undefined;\n }, MARKER_POINTER_EVENTS_RESET_DELAY_MS);\n };\n\n const temporarilyDisableMarkerPointerEvents = () => {\n setIsZoomInteractionActive(true);\n\n clearMarkerPointerEventsResetTimeout();\n\n if (disableMarkerPointerEventsWhileZoomingRef.current && !markerPointerEventsDisabledRef.current) {\n setMarkerPointerEventsDisabled(true);\n }\n };\n\n useEffect(() => {\n disableMarkerPointerEventsWhileZoomingRef.current = disableMarkerPointerEventsWhileZooming;\n }, [disableMarkerPointerEventsWhileZooming]);\n\n useEffect(() => {\n const mapElement = mapRef.current;\n\n if (!mapElement) {\n return;\n }\n\n const handleWheel = () => {\n temporarilyDisableMarkerPointerEvents();\n scheduleMarkerPointerEventsEnable();\n };\n\n mapElement.addEventListener('wheel', handleWheel, { passive: true, capture: true });\n\n return () => {\n mapElement.removeEventListener('wheel', handleWheel, { capture: true });\n };\n }, []);\n\n useEffect(() => {\n let allMapObjects: H.map.Object[] = [];\n let removeMapViewChangeListeners = () => {};\n\n if (api?.map) {\n allMapObjects = api.map.getObjects();\n console.debug('re-initialize here map');\n } else {\n console.debug('initialize here map');\n }\n\n if (api?.map) {\n // Cleanup any previously initialized map before doing anything else\n console.debug('disposing previous map');\n removeEventListenerMap(api.map);\n\n if (api.mapEvents) {\n api.mapEvents.dispose();\n }\n\n api.map.dispose();\n }\n\n const bounds = boundingBox && getMapBounds(boundingBox);\n\n // Initialize communication with the platform\n const platform = getPlatform(credentials);\n\n // Specify engine type. In this example, we use HARP rendering engine, which is capable\n // of rendering vector data using the style configuration exported from the HERE Style Editor.\n // HARP engine is not the default engine, and it's not included in the mapsjs-core.js module.\n // To use this engine, you need to include mapsjs-harp.js file to your HTML page\n const engineType = getEngineType(baseLayer, enableWebGL);\n\n // Obtain the default map types from the platform object\n // @ts-expect-error-next-line: according to the Here docs, the engine type exists\n // see https://www.here.com/docs/bundle/maps-api-for-javascript-developer-guide/page/topics/harp-migrate.html\n const defaultLayers = platform.createDefaultLayers({ engineType, lg: language, pois: true });\n\n getBaseLayer({\n baseLayerName: baseLayer,\n defaultLayers,\n enableWebGL,\n platform,\n engineType,\n vehicleRestrictions: activeLayers.includes(MAP_LAYER_ROAD_RESTRICTIONS),\n language,\n minZoom,\n maxZoom: safeMaxZoom,\n }).then(defaultLayerMap => {\n const handleMapViewChangeStart = () => {\n temporarilyDisableMarkerPointerEvents();\n };\n\n const handleMapViewChangeEnd = () => {\n scheduleMarkerPointerEventsEnable();\n };\n\n // Initialize the map\n const hereMap = new H.Map(mapRef.current as Element, defaultLayerMap.baseLayer, {\n zoom,\n center,\n bounds,\n engineType,\n pixelRatio: devicePixelRatio,\n fixedCenter: true,\n });\n\n if (defaultLayerMap.overlayLayer) {\n // Special case for satellite map where we render street labels and road signs as well as additional pois as vector data\n // hereMap.setBaseLayer(defaultLayerMap.baseLayer);\n hereMap.addLayer(defaultLayerMap.overlayLayer);\n }\n\n setMapInitialized(true);\n\n let hereMapEvents: H.mapevents.MapEvents | false = false;\n let hereBehavior: H.mapevents.Behavior | undefined;\n\n if (!disableMapEvents) {\n // Enable the map event system\n hereMapEvents = new H.mapevents.MapEvents(hereMap);\n }\n\n if (!(disableMapEvents || disableBehavior)) {\n hereBehavior = new H.mapevents.Behavior(hereMapEvents as H.mapevents.MapEvents);\n if (!enableFractionalZoom) {\n // Fractional zoom feels less predictable with mouse wheels in some setups,\n // but keeping it enabled can noticeably improve trackpad zoom smoothness.\n // @ts-expect-error-next-line\n hereBehavior.disable(H.mapevents.Behavior.Feature.FRACTIONAL_ZOOM);\n }\n\n if (disableZoomMomentum) {\n // Disable the inertia that occurs on WebGL maps when scrolling/zooming.\n // This resulted in a very high scroll sensitivity.\n // @ts-expect-error-next-line\n hereBehavior.disable(H.mapevents.Behavior.Feature.ZOOM_MOMENTUM);\n }\n }\n\n addEventListenerMap(hereMap, eventListenerMap, hereMap);\n hereMap.addEventListener('mapviewchangestart', handleMapViewChangeStart as EventListener);\n hereMap.addEventListener('mapviewchangeend', handleMapViewChangeEnd as EventListener);\n\n const hereUi = getHereUi(hereMap, defaultLayers, showScaleBar, language);\n\n // The api will be passed to services when using a render function.\n // This allows the service to access the map internals\n setApi({\n credentials,\n defaultLayers,\n map: hereMap,\n mapEvents: hereMapEvents,\n behavior: hereBehavior,\n platform,\n ui: hereUi,\n utils: createUtils(hereMap),\n // Put settings back into the map API object so the invoking service\n // can check on these settings for instance inside a test\n settings: {\n enableWebGL,\n baseLayer,\n activeLayers,\n showCluster,\n minZoom,\n maxZoom: safeMaxZoom,\n },\n });\n\n if (allMapObjects) {\n // If the base layer changed, re-add all previous objects again,\n // otherwise the map would be empty\n hereMap.addObjects(allMapObjects);\n }\n\n removeMapViewChangeListeners = () => {\n hereMap.removeEventListener('mapviewchangestart', handleMapViewChangeStart as EventListener);\n hereMap.removeEventListener('mapviewchangeend', handleMapViewChangeEnd as EventListener);\n };\n });\n\n return () => {\n removeMapViewChangeListeners();\n clearMarkerPointerEventsResetTimeout();\n setMarkerPointerEventsDisabled(false);\n setIsZoomInteractionActive(false);\n };\n }, [\n enableWebGL,\n enableDevicePixelRatio,\n language,\n baseLayer,\n minZoom,\n maxZoom,\n disableZoomMomentum,\n enableFractionalZoom,\n ]);\n\n useEffect(() => {\n if (!disableMarkerPointerEventsWhileZooming) {\n clearMarkerPointerEventsResetTimeout();\n setMarkerPointerEventsDisabled(false);\n }\n\n return () => {\n clearMarkerPointerEventsResetTimeout();\n setMarkerPointerEventsDisabled(false);\n setIsZoomInteractionActive(false);\n };\n }, [disableMarkerPointerEventsWhileZooming]);\n\n const isDarkMode = useDarkMode();\n useEffect(() => {\n // Toggle night map only if current map type is default\n if (isDarkMode && baseLayer === MAP_TYPE_DEFAULT) {\n handleMapTypeChange(MAP_TYPE_NIGHT);\n }\n // Toggle back to default map only if current map type is night\n else if (!isDarkMode && baseLayer === MAP_TYPE_NIGHT) {\n handleMapTypeChange(MAP_TYPE_DEFAULT);\n }\n }, [isDarkMode, language]);\n\n // Update MapType from outside\n useEffect(() => handleMapTypeChange(mapType), [mapType]);\n\n // Update MapLayer from outside\n const [previousMapLayer, setPreviousMapLayer] = useState(mapLayer);\n if (!isEqual(mapLayer, previousMapLayer)) {\n setActiveLayers(mapLayer);\n setPreviousMapLayer(mapLayer);\n }\n\n // Update Cluster setting from outside\n useEffect(() => setShowCluster(externalShowCluster), [externalShowCluster]);\n\n const handleMapTypeChange = (newMapType: MapType) => {\n setBaseLayer(newMapType);\n onMapTypeChange(newMapType, mapType);\n };\n\n const handleMapLayerChange = (layer: MapLayer) => {\n const removeLayer = (layerToRemove: string) => activeLayers.filter(item => item !== layerToRemove);\n const newActiveLayers = activeLayers.includes(layer) ? removeLayer(layer) : [...activeLayers, layer];\n setActiveLayers(newActiveLayers);\n onMapLayerChange(newActiveLayers, activeLayers);\n };\n\n const handleShowClusterChange = (newShowCluster: boolean) => {\n setShowCluster(newShowCluster);\n onShowClusterChange(newShowCluster);\n };\n\n // Note: For performance reasons, we deactivate pointer events and hence CSS style recalculation for the\n // the body. Having for instance many assets in the tree causes a performance loss when clicking on the map\n // to move it and zoom in/out since the map triggers a style invalidation and recalculation and\n // due to the nature of the AssetTree with it's hundreds DOM nodes, applying the CSS selectors\n // takes time.\n const handleMapInteractionStart = () => {\n document.querySelector('.AssetTree')?.classList.add('pointer-events-none');\n };\n const handleMapInteractionEnd = () => {\n document.querySelector('.AssetTree')?.classList.remove('pointer-events-none');\n };\n\n const style: CSSProperties = {};\n if (height) {\n style.height = height;\n }\n if (width) {\n style.width = width;\n }\n const autoHeightClass = isEmpty(style) ? 'height-100pct' : '';\n\n return (\n <div\n className={`Map position-relative map-type-${baseLayer.toLowerCase()} ${autoHeightClass}`}\n style={style}\n ref={mapRef}\n onTouchStart={handleMapInteractionStart}\n onTouchEnd={handleMapInteractionEnd}\n onMouseEnter={handleMapInteractionStart}\n onMouseOut={handleMapInteractionEnd}\n onBlur={handleMapInteractionEnd}\n >\n {isMapInitialized && api && (\n <MapContext.Provider\n value={{\n api,\n language,\n enableWebGL,\n enableMarkerIconCache,\n enableFractionalZoom,\n isZoomInteractionActive,\n showCluster,\n activeLayers,\n baseLayer,\n hideMapLayerSettings,\n hideClusterSettings,\n onMapTypeChange: handleMapTypeChange,\n onMapLayerChange: handleMapLayerChange,\n onShowClusterChange: handleShowClusterChange,\n mapSettingsTooltip,\n onIncidentsChange,\n devicePixelRatio,\n }}\n >\n <MapPosition api={api} boundingBox={boundingBox} center={center} zoomAnimation={zoomAnimation} />\n <MapSize api={api} />\n <MapZoom\n zoom={zoom}\n hideZoomButtons={disableBehavior}\n onZoomIn={onZoomIn}\n onZoomOut={onZoomOut}\n zoomAnimation={zoomAnimation}\n />\n {mapSettings && mapSettings}\n <MapOverlayLayers layers={activeLayers} />\n <MapElements api={api}>{children}</MapElements>\n </MapContext.Provider>\n )}\n </div>\n );\n};\n\nMap.TYPE_DEFAULT = MAP_TYPE_DEFAULT;\nMap.TYPE_FLEET_STYLE = MAP_TYPE_FLEET_STYLE;\nMap.TYPE_SATELLITE = MAP_TYPE_SATELLITE;\nMap.TYPE_TERRAIN = MAP_TYPE_TERRAIN;\nMap.TYPE_NIGHT = MAP_TYPE_NIGHT;\n\nMap.LAYER_INCIDENTS = MAP_LAYER_INCIDENTS;\nMap.LAYER_TRAFFIC = MAP_LAYER_TRAFFIC;\nMap.LAYER_ROAD_RESTRICTIONS = MAP_LAYER_ROAD_RESTRICTIONS;\n\nexport default Map;\n"],"names":["MARKER_POINTER_EVENTS_DISABLED_CLASS","MARKER_POINTER_EVENTS_RESET_DELAY_MS","Map","props","children","credentials","width","height","lang","center","zoom","zoomAnimation","boundingBox","hideClusterSettings","hideMapLayerSettings","disableMapEvents","disableBehavior","disableZoomMomentum","enableFractionalZoom","eventListenerMap","mapType","MAP_TYPE_DEFAULT","mapLayer","externalShowCluster","showScaleBar","onMapLayerChange","onMapTypeChange","onShowClusterChange","onZoomIn","onZoomOut","onIncidentsChange","mapSettingsTooltip","mapSettings","enableWebGL","enableDevicePixelRatio","enableMarkerIconCache","disableMarkerPointerEventsWhileZooming","pixelRatio","DEFAULT_PIXEL_RATIO","minZoom","DEFAULT_MIN_ZOOM","maxZoom","DEFAULT_MAX_ZOOM","safeMaxZoom","mapRef","useRef","markerPointerEventsResetTimeoutRef","markerPointerEventsDisabledRef","disableMarkerPointerEventsWhileZoomingRef","isMapInitialized","setMapInitialized","useState","isZoomInteractionActive","setIsZoomInteractionActive","api","setApi","baseLayer","setBaseLayer","activeLayers","setActiveLayers","showCluster","setShowCluster","devicePixelRatio","language","locale","setMarkerPointerEventsDisabled","disabled","mapElement","clearMarkerPointerEventsResetTimeout","scheduleMarkerPointerEventsEnable","temporarilyDisableMarkerPointerEvents","useEffect","handleWheel","allMapObjects","removeMapViewChangeListeners","removeEventListenerMap","bounds","getMapBounds","platform","getPlatform","engineType","getEngineType","defaultLayers","getBaseLayer","MAP_LAYER_ROAD_RESTRICTIONS","defaultLayerMap","handleMapViewChangeStart","handleMapViewChangeEnd","hereMap","hereMapEvents","hereBehavior","addEventListenerMap","hereUi","getHereUi","createUtils","isDarkMode","useDarkMode","handleMapTypeChange","MAP_TYPE_NIGHT","previousMapLayer","setPreviousMapLayer","isEqual","newMapType","handleMapLayerChange","layer","removeLayer","layerToRemove","item","newActiveLayers","handleShowClusterChange","newShowCluster","handleMapInteractionStart","handleMapInteractionEnd","style","autoHeightClass","isEmpty","jsx","jsxs","MapContext","MapPosition","MapSize","MapZoom","MapOverlayLayers","MapElements","MAP_TYPE_FLEET_STYLE","MAP_TYPE_SATELLITE","MAP_TYPE_TERRAIN","MAP_LAYER_INCIDENTS","MAP_LAYER_TRAFFIC"],"mappings":";;;;;;;;;;;;;;;;AA+BA,MAAMA,KAAuC,qCACvCC,KAAuC,KAEvCC,IAAM,CAACC,OAAoB;AAC7B,QAAM;AAAA,IACF,UAAAC;AAAA,IACA,aAAAC;AAAA,IACA,OAAAC;AAAA,IACA,QAAAC;AAAA,IACA,UAAUC,KAAO;AAAA,IACjB,QAAAC;AAAA,IACA,MAAAC;AAAA,IACA,eAAAC,IAAgB;AAAA,IAChB,aAAAC;AAAA,IACA,qBAAAC,KAAsB;AAAA,IACtB,sBAAAC,KAAuB;AAAA,IACvB,kBAAAC;AAAA,IACA,iBAAAC,IAAkB;AAAA,IAClB,qBAAAC,IAAsB;AAAA,IACtB,sBAAAC,IAAuB;AAAA,IACvB,kBAAAC;AAAA,IACA,SAAAC,IAAUC;AAAA,IACV,UAAAC,IAAW,CAAA;AAAA,IACX,aAAaC,IAAsB;AAAA,IACnC,cAAAC,KAAe;AAAA,IACf,kBAAAC,KAAmB,MAAM;AAAA,IAAC;AAAA,IAC1B,iBAAAC,KAAkB,MAAM;AAAA,IAAC;AAAA,IACzB,qBAAAC,KAAsB,MAAM;AAAA,IAAC;AAAA,IAC7B,UAAAC,KAAW,MAAM;AAAA,IAAC;AAAA,IAClB,WAAAC,KAAY,MAAM;AAAA,IAAC;AAAA,IACnB,mBAAAC,KAAoB,MAAM;AAAA,IAAC;AAAA,IAC3B,oBAAAC;AAAA,IACA,aAAAC;AAAA,IACA,aAAAC,IAAc;AAAA,IACd,wBAAAC,IAAyB;AAAA,IACzB,uBAAAC,KAAwB;AAAA,IACxB,wCAAAC,IAAyC;AAAA,IACzC,YAAAC,IAAaC;AAAA,IACb,SAAAC,IAAUC;AAAA,IACV,SAAAC,IAAUC;AAAA,EAAA,IAC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ACA,kBAAAgC;AAAA,UAAA;AAAA,UAGJ,UAAA;AAAA,YAAA,gBAAAsD,EAACG,IAAA,EAAY,KAAAjE,GAAU,aAAA1C,GAA0B,QAAAH,GAAgB,eAAAE,GAA8B;AAAA,YAC/F,gBAAAyG,EAACI,MAAQ,KAAAlE,GAAU;AAAA,YACnB,gBAAA8D;AAAA,cAACK;AAAA,cAAA;AAAA,gBACG,MAAA/G;AAAA,gBACA,iBAAiBM;AAAA,gBACjB,UAAAY;AAAA,gBACA,WAAAC;AAAA,gBACA,eAAAlB;AAAA,cAAA;AAAA,YAAA;AAAA,YAEHqB,KAAeA;AAAA,YAChB,gBAAAoF,EAACM,IAAA,EAAiB,QAAQhE,EAAA,CAAc;AAAA,YACxC,gBAAA0D,EAACO,IAAA,EAAY,KAAArE,GAAW,UAAAlD,GAAA,CAAS;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACrC;AAAA,EAAA;AAIhB;AAEAF,EAAI,eAAemB;AACnBnB,EAAI,mBAAmB0H;AACvB1H,EAAI,iBAAiB2H;AACrB3H,EAAI,eAAe4H;AACnB5H,EAAI,aAAagG;AAEjBhG,EAAI,kBAAkB6H;AACtB7H,EAAI,gBAAgB8H;AACpB9H,EAAI,0BAA0BkF;"}
1
+ {"version":3,"file":"Map.js","sources":["../../../../src/components/map/components/Map.tsx"],"sourcesContent":["import { useRef, useState, useEffect, useMemo, type CSSProperties } from 'react';\nimport { isEmpty } from 'es-toolkit/compat';\nimport { isEqual } from 'es-toolkit/predicate';\n\nimport {\n MAP_TYPE_DEFAULT,\n MAP_TYPE_FLEET_STYLE,\n MAP_TYPE_SATELLITE,\n MAP_TYPE_TERRAIN,\n MAP_TYPE_NIGHT,\n MAP_LAYER_INCIDENTS,\n MAP_LAYER_TRAFFIC,\n MAP_LAYER_ROAD_RESTRICTIONS,\n DEFAULT_MIN_ZOOM,\n DEFAULT_MAX_ZOOM,\n DEFAULT_PIXEL_RATIO,\n} from './constants';\n\nimport { addEventListenerMap, removeEventListenerMap } from '../utils/eventHandling';\nimport { MapContext } from './MapContext';\nimport { createUtils, getMapBounds } from '../utils/mapUtils';\nimport { getHereUi } from '../utils/mapUi';\nimport useDarkMode from '../../../hooks/useDarkMode';\nimport MapZoom from './features/MapZoom';\nimport MapOverlayLayers from './features/layers/MapOverlayLayers';\nimport MapSize from './MapSize';\nimport MapPosition from './MapPosition';\nimport MapElements from './MapElements';\nimport type { MapApi, MapLayer, MapProps, MapType } from '../utils/mapTypes';\nimport { getPlatform, getEngineType, getBaseLayer } from '../utils/rendering';\nimport { useMapViewportHistory } from '../hooks/useMapViewportHistory';\n\nconst MARKER_POINTER_EVENTS_DISABLED_CLASS = 'map-disable-marker-pointer-events';\nconst MARKER_POINTER_EVENTS_RESET_DELAY_MS = 140;\n\nconst Map = (props: MapProps) => {\n const {\n children,\n credentials,\n width,\n height,\n language: lang = 'en',\n center,\n zoom,\n zoomAnimation = false,\n boundingBox,\n hideClusterSettings = false,\n hideMapLayerSettings = false,\n disableMapEvents,\n disableBehavior = false,\n disableZoomMomentum = true,\n enableFractionalZoom = false,\n eventListenerMap,\n mapType = MAP_TYPE_DEFAULT,\n mapLayer = [],\n showCluster: externalShowCluster = true,\n showScaleBar = false,\n onMapLayerChange = () => {},\n onMapTypeChange = () => {},\n onShowClusterChange = () => {},\n onZoomIn = () => {},\n onZoomOut = () => {},\n onIncidentsChange = () => {},\n mapSettingsTooltip,\n mapSettings,\n maxViewportHistoryEntries,\n enableWebGL = true,\n enableDevicePixelRatio = true,\n enableMarkerIconCache = true,\n disableMarkerPointerEventsWhileZooming = false,\n pixelRatio = DEFAULT_PIXEL_RATIO,\n minZoom = DEFAULT_MIN_ZOOM,\n maxZoom = DEFAULT_MAX_ZOOM,\n } = props;\n\n let safeMaxZoom = maxZoom;\n\n if (minZoom > maxZoom) {\n // Avoid crashing the map for invalid zoom limits\n safeMaxZoom = DEFAULT_MAX_ZOOM;\n console.error('Invalid condition for zoom limits: min <= max)');\n }\n\n const mapRef = useRef<HTMLDivElement>(null);\n const markerPointerEventsResetTimeoutRef = useRef<number | undefined>();\n const markerPointerEventsDisabledRef = useRef(false);\n const disableMarkerPointerEventsWhileZoomingRef = useRef(disableMarkerPointerEventsWhileZooming);\n\n const [isMapInitialized, setMapInitialized] = useState(false);\n const [isZoomInteractionActive, setIsZoomInteractionActive] = useState(false);\n\n const [api, setApi] = useState<MapApi>();\n\n const [baseLayer, setBaseLayer] = useState<MapType>(mapType);\n const [activeLayers, setActiveLayers] = useState<MapLayer[]>(mapLayer);\n const [showCluster, setShowCluster] = useState(externalShowCluster);\n const controlledViewport = useMemo(\n () => (center && zoom !== undefined ? { center, zoom } : undefined),\n [center?.lat, center?.lng, zoom]\n );\n const viewportHistory = useMapViewportHistory(api, {\n maxEntries: maxViewportHistoryEntries,\n zoomAnimation,\n controlledViewport,\n });\n\n const devicePixelRatio = enableDevicePixelRatio ? window.devicePixelRatio || pixelRatio : pixelRatio;\n\n // Only short locale is supported by HERE Map\n const language = (locale => (locale === 'nb' ? 'no' : locale))(lang.split('-')[0].toLowerCase());\n\n const setMarkerPointerEventsDisabled = (disabled: boolean) => {\n if (disabled && !disableMarkerPointerEventsWhileZoomingRef.current) {\n return;\n }\n\n const mapElement = mapRef.current;\n\n if (!mapElement) {\n return;\n }\n\n mapElement.classList.toggle(MARKER_POINTER_EVENTS_DISABLED_CLASS, disabled);\n markerPointerEventsDisabledRef.current = disabled;\n };\n\n const clearMarkerPointerEventsResetTimeout = () => {\n if (markerPointerEventsResetTimeoutRef.current !== undefined) {\n window.clearTimeout(markerPointerEventsResetTimeoutRef.current);\n markerPointerEventsResetTimeoutRef.current = undefined;\n }\n };\n\n const scheduleMarkerPointerEventsEnable = () => {\n clearMarkerPointerEventsResetTimeout();\n markerPointerEventsResetTimeoutRef.current = window.setTimeout(() => {\n setMarkerPointerEventsDisabled(false);\n setIsZoomInteractionActive(false);\n markerPointerEventsResetTimeoutRef.current = undefined;\n }, MARKER_POINTER_EVENTS_RESET_DELAY_MS);\n };\n\n const temporarilyDisableMarkerPointerEvents = () => {\n setIsZoomInteractionActive(true);\n\n clearMarkerPointerEventsResetTimeout();\n\n if (disableMarkerPointerEventsWhileZoomingRef.current && !markerPointerEventsDisabledRef.current) {\n setMarkerPointerEventsDisabled(true);\n }\n };\n\n useEffect(() => {\n disableMarkerPointerEventsWhileZoomingRef.current = disableMarkerPointerEventsWhileZooming;\n }, [disableMarkerPointerEventsWhileZooming]);\n\n useEffect(() => {\n const mapElement = mapRef.current;\n\n if (!mapElement) {\n return;\n }\n\n const handleWheel = () => {\n temporarilyDisableMarkerPointerEvents();\n scheduleMarkerPointerEventsEnable();\n };\n\n mapElement.addEventListener('wheel', handleWheel, { passive: true, capture: true });\n\n return () => {\n mapElement.removeEventListener('wheel', handleWheel, { capture: true });\n };\n }, []);\n\n useEffect(() => {\n let allMapObjects: H.map.Object[] = [];\n let removeMapViewChangeListeners = () => {};\n\n if (api?.map) {\n allMapObjects = api.map.getObjects();\n console.debug('re-initialize here map');\n } else {\n console.debug('initialize here map');\n }\n\n if (api?.map) {\n // Cleanup any previously initialized map before doing anything else\n console.debug('disposing previous map');\n removeEventListenerMap(api.map);\n\n if (api.mapEvents) {\n api.mapEvents.dispose();\n }\n\n api.map.dispose();\n }\n\n const bounds = boundingBox && getMapBounds(boundingBox);\n\n // Initialize communication with the platform\n const platform = getPlatform(credentials);\n\n // Specify engine type. In this example, we use HARP rendering engine, which is capable\n // of rendering vector data using the style configuration exported from the HERE Style Editor.\n // HARP engine is not the default engine, and it's not included in the mapsjs-core.js module.\n // To use this engine, you need to include mapsjs-harp.js file to your HTML page\n const engineType = getEngineType(baseLayer, enableWebGL);\n\n // Obtain the default map types from the platform object\n // @ts-expect-error-next-line: according to the Here docs, the engine type exists\n // see https://www.here.com/docs/bundle/maps-api-for-javascript-developer-guide/page/topics/harp-migrate.html\n const defaultLayers = platform.createDefaultLayers({ engineType, lg: language, pois: true });\n\n getBaseLayer({\n baseLayerName: baseLayer,\n defaultLayers,\n enableWebGL,\n platform,\n engineType,\n vehicleRestrictions: activeLayers.includes(MAP_LAYER_ROAD_RESTRICTIONS),\n language,\n minZoom,\n maxZoom: safeMaxZoom,\n }).then(defaultLayerMap => {\n const handleMapViewChangeStart = () => {\n temporarilyDisableMarkerPointerEvents();\n };\n\n const handleMapViewChangeEnd = () => {\n scheduleMarkerPointerEventsEnable();\n };\n\n // Initialize the map\n const hereMap = new H.Map(mapRef.current as Element, defaultLayerMap.baseLayer, {\n zoom,\n center,\n bounds,\n engineType,\n pixelRatio: devicePixelRatio,\n fixedCenter: true,\n });\n\n if (defaultLayerMap.overlayLayer) {\n // Special case for satellite map where we render street labels and road signs as well as additional pois as vector data\n // hereMap.setBaseLayer(defaultLayerMap.baseLayer);\n hereMap.addLayer(defaultLayerMap.overlayLayer);\n }\n\n setMapInitialized(true);\n\n let hereMapEvents: H.mapevents.MapEvents | false = false;\n let hereBehavior: H.mapevents.Behavior | undefined;\n\n if (!disableMapEvents) {\n // Enable the map event system\n hereMapEvents = new H.mapevents.MapEvents(hereMap);\n }\n\n if (!(disableMapEvents || disableBehavior)) {\n hereBehavior = new H.mapevents.Behavior(hereMapEvents as H.mapevents.MapEvents);\n if (!enableFractionalZoom) {\n // Fractional zoom feels less predictable with mouse wheels in some setups,\n // but keeping it enabled can noticeably improve trackpad zoom smoothness.\n // @ts-expect-error-next-line\n hereBehavior.disable(H.mapevents.Behavior.Feature.FRACTIONAL_ZOOM);\n }\n\n if (disableZoomMomentum) {\n // Disable the inertia that occurs on WebGL maps when scrolling/zooming.\n // This resulted in a very high scroll sensitivity.\n // @ts-expect-error-next-line\n hereBehavior.disable(H.mapevents.Behavior.Feature.ZOOM_MOMENTUM);\n }\n }\n\n addEventListenerMap(hereMap, eventListenerMap, hereMap);\n hereMap.addEventListener('mapviewchangestart', handleMapViewChangeStart as EventListener);\n hereMap.addEventListener('mapviewchangeend', handleMapViewChangeEnd as EventListener);\n\n const hereUi = getHereUi(hereMap, defaultLayers, showScaleBar, language);\n\n // The api will be passed to services when using a render function.\n // This allows the service to access the map internals\n setApi({\n credentials,\n defaultLayers,\n map: hereMap,\n mapEvents: hereMapEvents,\n behavior: hereBehavior,\n platform,\n ui: hereUi,\n utils: createUtils(hereMap),\n // Put settings back into the map API object so the invoking service\n // can check on these settings for instance inside a test\n settings: {\n enableWebGL,\n baseLayer,\n activeLayers,\n showCluster,\n minZoom,\n maxZoom: safeMaxZoom,\n },\n });\n\n if (allMapObjects) {\n // If the base layer changed, re-add all previous objects again,\n // otherwise the map would be empty\n hereMap.addObjects(allMapObjects);\n }\n\n removeMapViewChangeListeners = () => {\n hereMap.removeEventListener('mapviewchangestart', handleMapViewChangeStart as EventListener);\n hereMap.removeEventListener('mapviewchangeend', handleMapViewChangeEnd as EventListener);\n };\n });\n\n return () => {\n removeMapViewChangeListeners();\n clearMarkerPointerEventsResetTimeout();\n setMarkerPointerEventsDisabled(false);\n setIsZoomInteractionActive(false);\n };\n }, [\n enableWebGL,\n enableDevicePixelRatio,\n language,\n baseLayer,\n minZoom,\n maxZoom,\n disableZoomMomentum,\n enableFractionalZoom,\n ]);\n\n useEffect(() => {\n if (!disableMarkerPointerEventsWhileZooming) {\n clearMarkerPointerEventsResetTimeout();\n setMarkerPointerEventsDisabled(false);\n }\n\n return () => {\n clearMarkerPointerEventsResetTimeout();\n setMarkerPointerEventsDisabled(false);\n setIsZoomInteractionActive(false);\n };\n }, [disableMarkerPointerEventsWhileZooming]);\n\n const isDarkMode = useDarkMode();\n useEffect(() => {\n // Toggle night map only if current map type is default\n if (isDarkMode && baseLayer === MAP_TYPE_DEFAULT) {\n handleMapTypeChange(MAP_TYPE_NIGHT);\n }\n // Toggle back to default map only if current map type is night\n else if (!isDarkMode && baseLayer === MAP_TYPE_NIGHT) {\n handleMapTypeChange(MAP_TYPE_DEFAULT);\n }\n }, [isDarkMode, language]);\n\n // Update MapType from outside\n useEffect(() => handleMapTypeChange(mapType), [mapType]);\n\n // Update MapLayer from outside\n const [previousMapLayer, setPreviousMapLayer] = useState(mapLayer);\n if (!isEqual(mapLayer, previousMapLayer)) {\n setActiveLayers(mapLayer);\n setPreviousMapLayer(mapLayer);\n }\n\n // Update Cluster setting from outside\n useEffect(() => setShowCluster(externalShowCluster), [externalShowCluster]);\n\n const handleMapTypeChange = (newMapType: MapType) => {\n setBaseLayer(newMapType);\n onMapTypeChange(newMapType, mapType);\n };\n\n const handleMapLayerChange = (layer: MapLayer) => {\n const removeLayer = (layerToRemove: string) => activeLayers.filter(item => item !== layerToRemove);\n const newActiveLayers = activeLayers.includes(layer) ? removeLayer(layer) : [...activeLayers, layer];\n setActiveLayers(newActiveLayers);\n onMapLayerChange(newActiveLayers, activeLayers);\n };\n\n const handleShowClusterChange = (newShowCluster: boolean) => {\n setShowCluster(newShowCluster);\n onShowClusterChange(newShowCluster);\n };\n\n // Note: For performance reasons, we deactivate pointer events and hence CSS style recalculation for the\n // the body. Having for instance many assets in the tree causes a performance loss when clicking on the map\n // to move it and zoom in/out since the map triggers a style invalidation and recalculation and\n // due to the nature of the AssetTree with it's hundreds DOM nodes, applying the CSS selectors\n // takes time.\n const handleMapInteractionStart = () => {\n document.querySelector('.AssetTree')?.classList.add('pointer-events-none');\n };\n const handleMapInteractionEnd = () => {\n document.querySelector('.AssetTree')?.classList.remove('pointer-events-none');\n };\n\n const style: CSSProperties = {};\n if (height) {\n style.height = height;\n }\n if (width) {\n style.width = width;\n }\n const autoHeightClass = isEmpty(style) ? 'height-100pct' : '';\n\n return (\n <div\n className={`Map position-relative map-type-${baseLayer.toLowerCase()} ${autoHeightClass}`}\n style={style}\n ref={mapRef}\n onTouchStart={handleMapInteractionStart}\n onTouchEnd={handleMapInteractionEnd}\n onMouseEnter={handleMapInteractionStart}\n onMouseOut={handleMapInteractionEnd}\n onBlur={handleMapInteractionEnd}\n >\n {isMapInitialized && api && (\n <MapContext.Provider\n value={{\n api,\n language,\n enableWebGL,\n enableMarkerIconCache,\n enableFractionalZoom,\n isZoomInteractionActive,\n showCluster,\n activeLayers,\n baseLayer,\n hideMapLayerSettings,\n hideClusterSettings,\n viewportHistory,\n onMapTypeChange: handleMapTypeChange,\n onMapLayerChange: handleMapLayerChange,\n onShowClusterChange: handleShowClusterChange,\n mapSettingsTooltip,\n onIncidentsChange,\n devicePixelRatio,\n }}\n >\n <MapPosition\n api={api}\n boundingBox={boundingBox}\n center={center}\n zoom={zoom}\n zoomAnimation={zoomAnimation}\n />\n <MapSize api={api} />\n <MapZoom\n hideZoomButtons={disableBehavior}\n onZoomIn={onZoomIn}\n onZoomOut={onZoomOut}\n zoomAnimation={zoomAnimation}\n />\n {mapSettings && mapSettings}\n <MapOverlayLayers layers={activeLayers} />\n <MapElements api={api}>{children}</MapElements>\n </MapContext.Provider>\n )}\n </div>\n );\n};\n\nMap.TYPE_DEFAULT = MAP_TYPE_DEFAULT;\nMap.TYPE_FLEET_STYLE = MAP_TYPE_FLEET_STYLE;\nMap.TYPE_SATELLITE = MAP_TYPE_SATELLITE;\nMap.TYPE_TERRAIN = MAP_TYPE_TERRAIN;\nMap.TYPE_NIGHT = MAP_TYPE_NIGHT;\n\nMap.LAYER_INCIDENTS = MAP_LAYER_INCIDENTS;\nMap.LAYER_TRAFFIC = MAP_LAYER_TRAFFIC;\nMap.LAYER_ROAD_RESTRICTIONS = MAP_LAYER_ROAD_RESTRICTIONS;\n\nexport default Map;\n"],"names":["MARKER_POINTER_EVENTS_DISABLED_CLASS","MARKER_POINTER_EVENTS_RESET_DELAY_MS","Map","props","children","credentials","width","height","lang","center","zoom","zoomAnimation","boundingBox","hideClusterSettings","hideMapLayerSettings","disableMapEvents","disableBehavior","disableZoomMomentum","enableFractionalZoom","eventListenerMap","mapType","MAP_TYPE_DEFAULT","mapLayer","externalShowCluster","showScaleBar","onMapLayerChange","onMapTypeChange","onShowClusterChange","onZoomIn","onZoomOut","onIncidentsChange","mapSettingsTooltip","mapSettings","maxViewportHistoryEntries","enableWebGL","enableDevicePixelRatio","enableMarkerIconCache","disableMarkerPointerEventsWhileZooming","pixelRatio","DEFAULT_PIXEL_RATIO","minZoom","DEFAULT_MIN_ZOOM","maxZoom","DEFAULT_MAX_ZOOM","safeMaxZoom","mapRef","useRef","markerPointerEventsResetTimeoutRef","markerPointerEventsDisabledRef","disableMarkerPointerEventsWhileZoomingRef","isMapInitialized","setMapInitialized","useState","isZoomInteractionActive","setIsZoomInteractionActive","api","setApi","baseLayer","setBaseLayer","activeLayers","setActiveLayers","showCluster","setShowCluster","controlledViewport","useMemo","viewportHistory","useMapViewportHistory","devicePixelRatio","language","locale","setMarkerPointerEventsDisabled","disabled","mapElement","clearMarkerPointerEventsResetTimeout","scheduleMarkerPointerEventsEnable","temporarilyDisableMarkerPointerEvents","useEffect","handleWheel","allMapObjects","removeMapViewChangeListeners","removeEventListenerMap","bounds","getMapBounds","platform","getPlatform","engineType","getEngineType","defaultLayers","getBaseLayer","MAP_LAYER_ROAD_RESTRICTIONS","defaultLayerMap","handleMapViewChangeStart","handleMapViewChangeEnd","hereMap","hereMapEvents","hereBehavior","addEventListenerMap","hereUi","getHereUi","createUtils","isDarkMode","useDarkMode","handleMapTypeChange","MAP_TYPE_NIGHT","previousMapLayer","setPreviousMapLayer","isEqual","newMapType","handleMapLayerChange","layer","removeLayer","layerToRemove","item","newActiveLayers","handleShowClusterChange","newShowCluster","handleMapInteractionStart","handleMapInteractionEnd","style","autoHeightClass","isEmpty","jsx","jsxs","MapContext","MapPosition","MapSize","MapZoom","MapOverlayLayers","MapElements","MAP_TYPE_FLEET_STYLE","MAP_TYPE_SATELLITE","MAP_TYPE_TERRAIN","MAP_LAYER_INCIDENTS","MAP_LAYER_TRAFFIC"],"mappings":";;;;;;;;;;;;;;;;;AAgCA,MAAMA,KAAuC,qCACvCC,KAAuC,KAEvCC,IAAM,CAACC,OAAoB;AAC7B,QAAM;AAAA,IACF,UAAAC;AAAA,IACA,aAAAC;AAAA,IACA,OAAAC;AAAA,IACA,QAAAC;AAAA,IACA,UAAUC,KAAO;AAA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;AAAA,cAACG;AAAA,cAAA;AAAA,gBACG,KAAArE;AAAA,gBACA,aAAA3C;AAAA,gBACA,QAAAH;AAAA,gBACA,MAAAC;AAAA,gBACA,eAAAC;AAAA,cAAA;AAAA,YAAA;AAAA,YAEJ,gBAAA8G,EAACI,MAAQ,KAAAtE,GAAU;AAAA,YACnB,gBAAAkE;AAAA,cAACK;AAAA,cAAA;AAAA,gBACG,iBAAiB9G;AAAA,gBACjB,UAAAY;AAAA,gBACA,WAAAC;AAAA,gBACA,eAAAlB;AAAA,cAAA;AAAA,YAAA;AAAA,YAEHqB,KAAeA;AAAA,YAChB,gBAAAyF,EAACM,IAAA,EAAiB,QAAQpE,EAAA,CAAc;AAAA,YACxC,gBAAA8D,EAACO,IAAA,EAAY,KAAAzE,GAAW,UAAAnD,GAAA,CAAS;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACrC;AAAA,EAAA;AAIhB;AAEAF,EAAI,eAAemB;AACnBnB,EAAI,mBAAmB+H;AACvB/H,EAAI,iBAAiBgI;AACrBhI,EAAI,eAAeiI;AACnBjI,EAAI,aAAaqG;AAEjBrG,EAAI,kBAAkBkI;AACtBlI,EAAI,gBAAgBmI;AACpBnI,EAAI,0BAA0BuF;"}
@@ -1,4 +1,5 @@
1
1
  import { MapApi, MapIncidents, MapLayer, MapType } from '../utils/mapTypes';
2
+ import { MapViewportHistory } from '../hooks/useMapViewportHistory';
2
3
  export type MapContextType = {
3
4
  api: MapApi;
4
5
  language: string;
@@ -16,6 +17,7 @@ export type MapContextType = {
16
17
  mapSettingsTooltip?: string | React.ReactNode;
17
18
  hideMapLayerSettings?: boolean;
18
19
  hideClusterSettings?: boolean;
20
+ viewportHistory: MapViewportHistory;
19
21
  onIncidentsChange: (incidentsResult: MapIncidents) => void;
20
22
  };
21
23
  export declare const defaultMapContext: MapContextType;
@@ -1,22 +1,24 @@
1
1
  import { createContext as e, useContext as t } from "react";
2
- import { MAP_TYPE_DEFAULT as a } from "./constants.js";
3
- const o = {
2
+ import { MAP_TYPE_DEFAULT as o } from "./constants.js";
3
+ import { defaultMapViewportHistory as a } from "../hooks/useMapViewportHistory.js";
4
+ const r = {
4
5
  api: {},
5
6
  language: "en",
6
7
  enableWebGL: !0,
7
8
  enableMarkerIconCache: !0,
8
9
  enableFractionalZoom: !1,
9
10
  isZoomInteractionActive: !1,
10
- baseLayer: a,
11
+ baseLayer: o,
11
12
  activeLayers: [],
12
13
  showCluster: !0,
13
14
  devicePixelRatio: 1,
15
+ viewportHistory: a,
14
16
  onIncidentsChange: () => {
15
17
  }
16
- }, n = e(o), c = () => t(n);
18
+ }, n = e(r), l = () => t(n);
17
19
  export {
18
20
  n as MapContext,
19
- o as defaultMapContext,
20
- c as useMapContext
21
+ r as defaultMapContext,
22
+ l as useMapContext
21
23
  };
22
24
  //# sourceMappingURL=MapContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MapContext.js","sources":["../../../../src/components/map/components/MapContext.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\n\nimport type { MapApi, MapIncidents, MapLayer, MapType } from '../utils/mapTypes';\nimport { MAP_TYPE_DEFAULT } from './constants';\n\nexport type MapContextType = {\n api: MapApi;\n language: string;\n enableWebGL: boolean;\n enableMarkerIconCache: boolean;\n enableFractionalZoom: boolean;\n isZoomInteractionActive: boolean;\n baseLayer: MapType;\n activeLayers: MapLayer[];\n showCluster: boolean;\n devicePixelRatio: number;\n onMapTypeChange?: (type: MapType) => void;\n onMapLayerChange?: (layer: MapLayer) => void;\n onShowClusterChange?: (showCluster: boolean) => void;\n mapSettingsTooltip?: string | React.ReactNode;\n hideMapLayerSettings?: boolean;\n hideClusterSettings?: boolean;\n onIncidentsChange: (incidentsResult: MapIncidents) => void;\n};\n\nexport const defaultMapContext: MapContextType = {\n api: {},\n language: 'en',\n enableWebGL: true,\n enableMarkerIconCache: true,\n enableFractionalZoom: false,\n isZoomInteractionActive: false,\n baseLayer: MAP_TYPE_DEFAULT,\n activeLayers: [],\n showCluster: true,\n devicePixelRatio: 1,\n onIncidentsChange: () => {},\n};\n\nexport const MapContext = createContext<MapContextType>(defaultMapContext);\n\nexport const useMapContext = () => useContext(MapContext);\n"],"names":["defaultMapContext","MAP_TYPE_DEFAULT","MapContext","createContext","useMapContext","useContext"],"mappings":";;AAyBO,MAAMA,IAAoC;AAAA,EAC7C,KAAK,CAAA;AAAA,EACL,UAAU;AAAA,EACV,aAAa;AAAA,EACb,uBAAuB;AAAA,EACvB,sBAAsB;AAAA,EACtB,yBAAyB;AAAA,EACzB,WAAWC;AAAA,EACX,cAAc,CAAA;AAAA,EACd,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,mBAAmB,MAAM;AAAA,EAAC;AAC9B,GAEaC,IAAaC,EAA8BH,CAAiB,GAE5DI,IAAgB,MAAMC,EAAWH,CAAU;"}
1
+ {"version":3,"file":"MapContext.js","sources":["../../../../src/components/map/components/MapContext.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\n\nimport type { MapApi, MapIncidents, MapLayer, MapType } from '../utils/mapTypes';\nimport { MAP_TYPE_DEFAULT } from './constants';\nimport { defaultMapViewportHistory, type MapViewportHistory } from '../hooks/useMapViewportHistory';\n\nexport type MapContextType = {\n api: MapApi;\n language: string;\n enableWebGL: boolean;\n enableMarkerIconCache: boolean;\n enableFractionalZoom: boolean;\n isZoomInteractionActive: boolean;\n baseLayer: MapType;\n activeLayers: MapLayer[];\n showCluster: boolean;\n devicePixelRatio: number;\n onMapTypeChange?: (type: MapType) => void;\n onMapLayerChange?: (layer: MapLayer) => void;\n onShowClusterChange?: (showCluster: boolean) => void;\n mapSettingsTooltip?: string | React.ReactNode;\n hideMapLayerSettings?: boolean;\n hideClusterSettings?: boolean;\n viewportHistory: MapViewportHistory;\n onIncidentsChange: (incidentsResult: MapIncidents) => void;\n};\n\nexport const defaultMapContext: MapContextType = {\n api: {},\n language: 'en',\n enableWebGL: true,\n enableMarkerIconCache: true,\n enableFractionalZoom: false,\n isZoomInteractionActive: false,\n baseLayer: MAP_TYPE_DEFAULT,\n activeLayers: [],\n showCluster: true,\n devicePixelRatio: 1,\n viewportHistory: defaultMapViewportHistory,\n onIncidentsChange: () => {},\n};\n\nexport const MapContext = createContext<MapContextType>(defaultMapContext);\n\nexport const useMapContext = () => useContext(MapContext);\n"],"names":["defaultMapContext","MAP_TYPE_DEFAULT","defaultMapViewportHistory","MapContext","createContext","useMapContext","useContext"],"mappings":";;;AA2BO,MAAMA,IAAoC;AAAA,EAC7C,KAAK,CAAA;AAAA,EACL,UAAU;AAAA,EACV,aAAa;AAAA,EACb,uBAAuB;AAAA,EACvB,sBAAsB;AAAA,EACtB,yBAAyB;AAAA,EACzB,WAAWC;AAAA,EACX,cAAc,CAAA;AAAA,EACd,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,iBAAiBC;AAAA,EACjB,mBAAmB,MAAM;AAAA,EAAC;AAC9B,GAEaC,IAAaC,EAA8BJ,CAAiB,GAE5DK,IAAgB,MAAMC,EAAWH,CAAU;"}
@@ -1,5 +1,5 @@
1
1
  import { MapApi, MapProps } from '../utils/mapTypes';
2
- export type MapPositionProps = Pick<MapProps, 'boundingBox' | 'center' | 'zoomAnimation'> & {
2
+ export type MapPositionProps = Pick<MapProps, 'boundingBox' | 'center' | 'zoom' | 'zoomAnimation'> & {
3
3
  api: MapApi;
4
4
  };
5
5
  declare const MapPosition: (props: MapPositionProps) => null;
@@ -1,19 +1,26 @@
1
- import { useEffect as r } from "react";
2
- const c = (s) => {
3
- const { api: t, boundingBox: n, center: e, zoomAnimation: i = !1 } = s;
4
- return r(() => {
5
- if (t && n) {
6
- const { top: o, left: a, bottom: l, right: f } = n;
7
- t.map?.getViewModel().setLookAtData({ bounds: new H.geo.Rect(o, a, l, f) }, i);
1
+ import { useRef as f, useEffect as h } from "react";
2
+ import { useMapContext as P } from "./MapContext.js";
3
+ const C = 1e-6, Z = 1e-3, N = (b) => {
4
+ const { api: o, boundingBox: a, center: t, zoom: e, zoomAnimation: r = !1 } = b, { enableFractionalZoom: g } = P(), p = f(), c = f(t), d = f(e);
5
+ return h(() => {
6
+ if (o && a) {
7
+ const { top: n, left: i, bottom: l, right: u } = a;
8
+ o.map?.getViewModel().setLookAtData({ bounds: new H.geo.Rect(n, i, l, u) }, r);
8
9
  }
9
- }, [n]), r(() => {
10
- if (!(t && e))
10
+ }, [a]), h(() => {
11
+ const n = o.map;
12
+ if (!(n && (t || e !== void 0)))
11
13
  return;
12
- const o = t.utils?.getCenter();
13
- o && (o.lat !== e.lat || o.lng !== e.lng) && t.utils?.setCenter(e, i);
14
- }, [e]), null;
14
+ const i = p.current !== n, l = t?.lat !== c.current?.lat || t?.lng !== c.current?.lng, u = e !== d.current;
15
+ if (!(i || l || u))
16
+ return;
17
+ const s = {}, m = o.utils?.getCenter();
18
+ t && m && (Math.abs(m.lat - t.lat) > C || Math.abs(m.lng - t.lng) > C) && (s.position = t);
19
+ const M = g ? o.utils?.getPreciseZoom() : o.utils?.getZoom();
20
+ e !== void 0 && M !== void 0 && Math.abs(M - e) > Z && (s.zoom = e), Object.keys(s).length > 0 && n.getViewModel().setLookAtData(s, r), p.current = n, c.current = t, d.current = e;
21
+ }, [o, t, e, r, g]), null;
15
22
  };
16
23
  export {
17
- c as default
24
+ N as default
18
25
  };
19
26
  //# sourceMappingURL=MapPosition.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MapPosition.js","sources":["../../../../src/components/map/components/MapPosition.tsx"],"sourcesContent":["import { useEffect } from 'react';\n\nimport type { MapApi, MapProps } from '../utils/mapTypes';\n\nexport type MapPositionProps = Pick<MapProps, 'boundingBox' | 'center' | 'zoomAnimation'> & {\n api: MapApi;\n};\n\nconst MapPosition = (props: MapPositionProps) => {\n const { api, boundingBox, center, zoomAnimation = false } = props;\n\n // Update BoundingBox from outside\n useEffect(() => {\n if (api && boundingBox) {\n const { top, left, bottom, right } = boundingBox;\n api.map?.getViewModel().setLookAtData({ bounds: new H.geo.Rect(top, left, bottom, right) }, zoomAnimation);\n }\n }, [boundingBox]);\n\n // Update Lat & Lng from outside if value is different\n useEffect(() => {\n if (!(api && center)) {\n return;\n }\n\n const currentMapCenter = api.utils?.getCenter();\n if (currentMapCenter) {\n if (currentMapCenter.lat !== center.lat || currentMapCenter.lng !== center.lng) {\n api.utils?.setCenter(center, zoomAnimation);\n }\n }\n }, [center]);\n\n return null;\n};\n\nexport default MapPosition;\n"],"names":["MapPosition","props","api","boundingBox","center","zoomAnimation","useEffect","top","left","bottom","right","currentMapCenter"],"mappings":";AAQA,MAAMA,IAAc,CAACC,MAA4B;AAC7C,QAAM,EAAE,KAAAC,GAAK,aAAAC,GAAa,QAAAC,GAAQ,eAAAC,IAAgB,OAAUJ;AAG5D,SAAAK,EAAU,MAAM;AACZ,QAAIJ,KAAOC,GAAa;AACpB,YAAM,EAAE,KAAAI,GAAK,MAAAC,GAAM,QAAAC,GAAQ,OAAAC,MAAUP;AACrC,MAAAD,EAAI,KAAK,aAAA,EAAe,cAAc,EAAE,QAAQ,IAAI,EAAE,IAAI,KAAKK,GAAKC,GAAMC,GAAQC,CAAK,EAAA,GAAKL,CAAa;AAAA,IAC7G;AAAA,EACJ,GAAG,CAACF,CAAW,CAAC,GAGhBG,EAAU,MAAM;AACZ,QAAI,EAAEJ,KAAOE;AACT;AAGJ,UAAMO,IAAmBT,EAAI,OAAO,UAAA;AACpC,IAAIS,MACIA,EAAiB,QAAQP,EAAO,OAAOO,EAAiB,QAAQP,EAAO,QACvEF,EAAI,OAAO,UAAUE,GAAQC,CAAa;AAAA,EAGtD,GAAG,CAACD,CAAM,CAAC,GAEJ;AACX;"}
1
+ {"version":3,"file":"MapPosition.js","sources":["../../../../src/components/map/components/MapPosition.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\nimport type { MapApi, MapProps } from '../utils/mapTypes';\nimport { useMapContext } from './MapContext';\n\nconst CENTER_SYNC_EPSILON = 0.000001;\nconst ZOOM_SYNC_EPSILON = 0.001;\n\n// Keeps externally controlled viewport props in sync with HERE.\n// `center` and `zoom` may change together, but either value must also work independently.\nexport type MapPositionProps = Pick<MapProps, 'boundingBox' | 'center' | 'zoom' | 'zoomAnimation'> & {\n api: MapApi;\n};\n\nconst MapPosition = (props: MapPositionProps) => {\n const { api, boundingBox, center, zoom, zoomAnimation = false } = props;\n const { enableFractionalZoom } = useMapContext();\n const lastProcessedMapRef = useRef<H.Map>();\n const lastProcessedCenterRef = useRef(center);\n const lastProcessedZoomRef = useRef(zoom);\n\n // Update BoundingBox from outside\n useEffect(() => {\n if (api && boundingBox) {\n const { top, left, bottom, right } = boundingBox;\n api.map?.getViewModel().setLookAtData({ bounds: new H.geo.Rect(top, left, bottom, right) }, zoomAnimation);\n }\n }, [boundingBox]);\n\n // Update viewport from outside if center or zoom value is different.\n // If only zoom changed, HERE receives only `{ zoom }`; if only center changed, only `{ position }`.\n // If both changed in the same render, they are applied atomically to avoid animated zooming around the old center.\n useEffect(() => {\n const map = api.map;\n\n if (!(map && (center || zoom !== undefined))) {\n return;\n }\n\n const hasMapChanged = lastProcessedMapRef.current !== map;\n const hasCenterChanged =\n center?.lat !== lastProcessedCenterRef.current?.lat || center?.lng !== lastProcessedCenterRef.current?.lng;\n const hasZoomChanged = zoom !== lastProcessedZoomRef.current;\n\n if (!(hasMapChanged || hasCenterChanged || hasZoomChanged)) {\n return;\n }\n\n const lookAtData: H.map.ViewModel.ILookAtData = {};\n\n const currentMapCenter = api.utils?.getCenter();\n if (\n center &&\n currentMapCenter &&\n (Math.abs(currentMapCenter.lat - center.lat) > CENTER_SYNC_EPSILON ||\n Math.abs(currentMapCenter.lng - center.lng) > CENTER_SYNC_EPSILON)\n ) {\n lookAtData.position = center;\n }\n\n const currentMapZoom = enableFractionalZoom ? api.utils?.getPreciseZoom() : api.utils?.getZoom();\n if (zoom !== undefined && currentMapZoom !== undefined && Math.abs(currentMapZoom - zoom) > ZOOM_SYNC_EPSILON) {\n lookAtData.zoom = zoom;\n }\n\n if (Object.keys(lookAtData).length > 0) {\n map.getViewModel().setLookAtData(lookAtData, zoomAnimation);\n }\n\n lastProcessedMapRef.current = map;\n lastProcessedCenterRef.current = center;\n lastProcessedZoomRef.current = zoom;\n }, [api, center, zoom, zoomAnimation, enableFractionalZoom]);\n\n return null;\n};\n\nexport default MapPosition;\n"],"names":["CENTER_SYNC_EPSILON","ZOOM_SYNC_EPSILON","MapPosition","props","api","boundingBox","center","zoom","zoomAnimation","enableFractionalZoom","useMapContext","lastProcessedMapRef","useRef","lastProcessedCenterRef","lastProcessedZoomRef","useEffect","top","left","bottom","right","map","hasMapChanged","hasCenterChanged","hasZoomChanged","lookAtData","currentMapCenter","currentMapZoom"],"mappings":";;AAKA,MAAMA,IAAsB,MACtBC,IAAoB,MAQpBC,IAAc,CAACC,MAA4B;AAC7C,QAAM,EAAE,KAAAC,GAAK,aAAAC,GAAa,QAAAC,GAAQ,MAAAC,GAAM,eAAAC,IAAgB,OAAUL,GAC5D,EAAE,sBAAAM,EAAA,IAAyBC,EAAA,GAC3BC,IAAsBC,EAAA,GACtBC,IAAyBD,EAAON,CAAM,GACtCQ,IAAuBF,EAAOL,CAAI;AAGxC,SAAAQ,EAAU,MAAM;AACZ,QAAIX,KAAOC,GAAa;AACpB,YAAM,EAAE,KAAAW,GAAK,MAAAC,GAAM,QAAAC,GAAQ,OAAAC,MAAUd;AACrC,MAAAD,EAAI,KAAK,aAAA,EAAe,cAAc,EAAE,QAAQ,IAAI,EAAE,IAAI,KAAKY,GAAKC,GAAMC,GAAQC,CAAK,EAAA,GAAKX,CAAa;AAAA,IAC7G;AAAA,EACJ,GAAG,CAACH,CAAW,CAAC,GAKhBU,EAAU,MAAM;AACZ,UAAMK,IAAMhB,EAAI;AAEhB,QAAI,EAAEgB,MAAQd,KAAUC,MAAS;AAC7B;AAGJ,UAAMc,IAAgBV,EAAoB,YAAYS,GAChDE,IACFhB,GAAQ,QAAQO,EAAuB,SAAS,OAAOP,GAAQ,QAAQO,EAAuB,SAAS,KACrGU,IAAiBhB,MAASO,EAAqB;AAErD,QAAI,EAAEO,KAAiBC,KAAoBC;AACvC;AAGJ,UAAMC,IAA0C,CAAA,GAE1CC,IAAmBrB,EAAI,OAAO,UAAA;AACpC,IACIE,KACAmB,MACC,KAAK,IAAIA,EAAiB,MAAMnB,EAAO,GAAG,IAAIN,KAC3C,KAAK,IAAIyB,EAAiB,MAAMnB,EAAO,GAAG,IAAIN,OAElDwB,EAAW,WAAWlB;AAG1B,UAAMoB,IAAiBjB,IAAuBL,EAAI,OAAO,mBAAmBA,EAAI,OAAO,QAAA;AACvF,IAAIG,MAAS,UAAamB,MAAmB,UAAa,KAAK,IAAIA,IAAiBnB,CAAI,IAAIN,MACxFuB,EAAW,OAAOjB,IAGlB,OAAO,KAAKiB,CAAU,EAAE,SAAS,KACjCJ,EAAI,aAAA,EAAe,cAAcI,GAAYhB,CAAa,GAG9DG,EAAoB,UAAUS,GAC9BP,EAAuB,UAAUP,GACjCQ,EAAqB,UAAUP;AAAA,EACnC,GAAG,CAACH,GAAKE,GAAQC,GAAMC,GAAeC,CAAoB,CAAC,GAEpD;AACX;"}
@@ -1,5 +1,4 @@
1
1
  export type MapZoomProps = {
2
- zoom?: number;
3
2
  hideZoomButtons: boolean;
4
3
  zoomAnimation: boolean;
5
4
  onZoomIn: (zoom: number) => void;
@@ -1,25 +1,17 @@
1
- import { jsx as p } from "react/jsx-runtime";
2
- import { useRef as d, useEffect as O } from "react";
3
- import I from "./settings/ZoomButtons.js";
4
- import { useMapContext as M } from "../MapContext.js";
5
- const g = 1e-3, P = (i) => {
6
- const { zoom: t, hideZoomButtons: Z, zoomAnimation: r, onZoomIn: c, onZoomOut: a } = i, { api: o, enableFractionalZoom: m, isZoomInteractionActive: s } = M(), u = d();
7
- O(() => {
8
- if (!(o && t !== void 0) || u.current === t || m && s)
9
- return;
10
- const n = m ? o.utils?.getPreciseZoom() : o.utils?.getZoom();
11
- n !== void 0 && (m ? Math.abs(n - t) > g : n !== t) && o.utils?.setZoom(t, r), u.current = t;
12
- }, [o, t, r, m, s]);
13
- const l = () => {
14
- const e = (o?.utils?.getZoom() ?? 0) + 1;
15
- c(e), o?.utils?.setZoom(e, r);
16
- }, f = () => {
17
- const e = (o?.utils?.getZoom() ?? 0) - 1;
18
- a(e), o?.utils?.setZoom(e, r);
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import l from "./settings/ZoomButtons.js";
3
+ import { useMapContext as a } from "../MapContext.js";
4
+ const h = (m) => {
5
+ const { hideZoomButtons: s, zoomAnimation: n, onZoomIn: e, onZoomOut: r } = m, { api: t } = a(), Z = () => {
6
+ const o = (t?.utils?.getZoom() ?? 0) + 1;
7
+ e(o), t?.utils?.setZoom(o, n);
8
+ }, u = () => {
9
+ const o = (t?.utils?.getZoom() ?? 0) - 1;
10
+ r(o), t?.utils?.setZoom(o, n);
19
11
  };
20
- return Z ? null : /* @__PURE__ */ p(I, { onZoomIn: l, onZoomOut: f });
12
+ return s ? null : /* @__PURE__ */ i(l, { onZoomIn: Z, onZoomOut: u });
21
13
  };
22
14
  export {
23
- P as default
15
+ h as default
24
16
  };
25
17
  //# sourceMappingURL=MapZoom.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MapZoom.js","sources":["../../../../../src/components/map/components/features/MapZoom.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\nimport ZoomButtons from './settings/ZoomButtons';\nimport { useMapContext } from '../MapContext';\n\nconst ZOOM_SYNC_EPSILON = 0.001;\n\nexport type MapZoomProps = {\n zoom?: number;\n hideZoomButtons: boolean;\n zoomAnimation: boolean;\n onZoomIn: (zoom: number) => void;\n onZoomOut: (zoom: number) => void;\n};\n\nconst MapZoom = (props: MapZoomProps) => {\n const { zoom, hideZoomButtons, zoomAnimation, onZoomIn, onZoomOut } = props;\n\n const { api, enableFractionalZoom, isZoomInteractionActive } = useMapContext();\n const lastProcessedExternalZoomRef = useRef<number | undefined>();\n\n // Update Zoom from outside if value is different\n useEffect(() => {\n if (!(api && zoom !== undefined)) {\n return;\n }\n\n if (lastProcessedExternalZoomRef.current === zoom) {\n return;\n }\n\n if (enableFractionalZoom && isZoomInteractionActive) {\n return;\n }\n\n const currentMapZoom = enableFractionalZoom ? api.utils?.getPreciseZoom() : api.utils?.getZoom();\n\n if (\n currentMapZoom !== undefined &&\n (enableFractionalZoom ? Math.abs(currentMapZoom - zoom) > ZOOM_SYNC_EPSILON : currentMapZoom !== zoom)\n ) {\n api.utils?.setZoom(zoom, zoomAnimation);\n }\n\n lastProcessedExternalZoomRef.current = zoom;\n }, [api, zoom, zoomAnimation, enableFractionalZoom, isZoomInteractionActive]);\n\n const handleZoomIn = () => {\n const currentZoom = api?.utils?.getZoom() ?? 0;\n const newZoom = currentZoom + 1;\n\n onZoomIn(newZoom);\n api?.utils?.setZoom(newZoom, zoomAnimation);\n };\n\n const handleZoomOut = () => {\n const currentZoom = api?.utils?.getZoom() ?? 0;\n const newZoom = currentZoom - 1;\n\n onZoomOut(newZoom);\n api?.utils?.setZoom(newZoom, zoomAnimation);\n };\n\n if (hideZoomButtons) {\n return null;\n }\n\n return <ZoomButtons onZoomIn={handleZoomIn} onZoomOut={handleZoomOut} />;\n};\n\nexport default MapZoom;\n"],"names":["ZOOM_SYNC_EPSILON","MapZoom","props","zoom","hideZoomButtons","zoomAnimation","onZoomIn","onZoomOut","api","enableFractionalZoom","isZoomInteractionActive","useMapContext","lastProcessedExternalZoomRef","useRef","useEffect","currentMapZoom","handleZoomIn","newZoom","handleZoomOut","jsx","ZoomButtons"],"mappings":";;;;AAKA,MAAMA,IAAoB,MAUpBC,IAAU,CAACC,MAAwB;AACrC,QAAM,EAAE,MAAAC,GAAM,iBAAAC,GAAiB,eAAAC,GAAe,UAAAC,GAAU,WAAAC,MAAcL,GAEhE,EAAE,KAAAM,GAAK,sBAAAC,GAAsB,yBAAAC,EAAA,IAA4BC,EAAA,GACzDC,IAA+BC,EAAA;AAGrC,EAAAC,EAAU,MAAM;AASZ,QARI,EAAEN,KAAOL,MAAS,WAIlBS,EAA6B,YAAYT,KAIzCM,KAAwBC;AACxB;AAGJ,UAAMK,IAAiBN,IAAuBD,EAAI,OAAO,mBAAmBA,EAAI,OAAO,QAAA;AAEvF,IACIO,MAAmB,WAClBN,IAAuB,KAAK,IAAIM,IAAiBZ,CAAI,IAAIH,IAAoBe,MAAmBZ,MAEjGK,EAAI,OAAO,QAAQL,GAAME,CAAa,GAG1CO,EAA6B,UAAUT;AAAA,EAC3C,GAAG,CAACK,GAAKL,GAAME,GAAeI,GAAsBC,CAAuB,CAAC;AAE5E,QAAMM,IAAe,MAAM;AAEvB,UAAMC,KADcT,GAAK,OAAO,QAAA,KAAa,KACf;AAE9B,IAAAF,EAASW,CAAO,GAChBT,GAAK,OAAO,QAAQS,GAASZ,CAAa;AAAA,EAC9C,GAEMa,IAAgB,MAAM;AAExB,UAAMD,KADcT,GAAK,OAAO,QAAA,KAAa,KACf;AAE9B,IAAAD,EAAUU,CAAO,GACjBT,GAAK,OAAO,QAAQS,GAASZ,CAAa;AAAA,EAC9C;AAEA,SAAID,IACO,OAGJ,gBAAAe,EAACC,GAAA,EAAY,UAAUJ,GAAc,WAAWE,GAAe;AAC1E;"}
1
+ {"version":3,"file":"MapZoom.js","sources":["../../../../../src/components/map/components/features/MapZoom.tsx"],"sourcesContent":["import ZoomButtons from './settings/ZoomButtons';\nimport { useMapContext } from '../MapContext';\n\nexport type MapZoomProps = {\n hideZoomButtons: boolean;\n zoomAnimation: boolean;\n onZoomIn: (zoom: number) => void;\n onZoomOut: (zoom: number) => void;\n};\n\nconst MapZoom = (props: MapZoomProps) => {\n const { hideZoomButtons, zoomAnimation, onZoomIn, onZoomOut } = props;\n\n const { api } = useMapContext();\n\n const handleZoomIn = () => {\n const currentZoom = api?.utils?.getZoom() ?? 0;\n const newZoom = currentZoom + 1;\n\n onZoomIn(newZoom);\n api?.utils?.setZoom(newZoom, zoomAnimation);\n };\n\n const handleZoomOut = () => {\n const currentZoom = api?.utils?.getZoom() ?? 0;\n const newZoom = currentZoom - 1;\n\n onZoomOut(newZoom);\n api?.utils?.setZoom(newZoom, zoomAnimation);\n };\n\n if (hideZoomButtons) {\n return null;\n }\n\n return <ZoomButtons onZoomIn={handleZoomIn} onZoomOut={handleZoomOut} />;\n};\n\nexport default MapZoom;\n"],"names":["MapZoom","props","hideZoomButtons","zoomAnimation","onZoomIn","onZoomOut","api","useMapContext","handleZoomIn","newZoom","handleZoomOut","jsx","ZoomButtons"],"mappings":";;;AAUA,MAAMA,IAAU,CAACC,MAAwB;AACrC,QAAM,EAAE,iBAAAC,GAAiB,eAAAC,GAAe,UAAAC,GAAU,WAAAC,MAAcJ,GAE1D,EAAE,KAAAK,EAAA,IAAQC,EAAA,GAEVC,IAAe,MAAM;AAEvB,UAAMC,KADcH,GAAK,OAAO,QAAA,KAAa,KACf;AAE9B,IAAAF,EAASK,CAAO,GAChBH,GAAK,OAAO,QAAQG,GAASN,CAAa;AAAA,EAC9C,GAEMO,IAAgB,MAAM;AAExB,UAAMD,KADcH,GAAK,OAAO,QAAA,KAAa,KACf;AAE9B,IAAAD,EAAUI,CAAO,GACjBH,GAAK,OAAO,QAAQG,GAASN,CAAa;AAAA,EAC9C;AAEA,SAAID,IACO,OAGJ,gBAAAS,EAACC,GAAA,EAAY,UAAUJ,GAAc,WAAWE,GAAe;AAC1E;"}
@@ -2,5 +2,6 @@ export declare const CLUSTER_ICON_WIDTH = 34;
2
2
  export declare const CLUSTER_ICON_HEIGHT = 38;
3
3
  export declare const MARKER_ICON_WIDTH = 26;
4
4
  export declare const MARKER_ICON_HEIGHT = 31;
5
+ export declare const buildTrafficIncidentsUrl: (area: string, apiKey?: string, language?: string) => string;
5
6
  declare const IncidentsLayer: () => null;
6
7
  export default IncidentsLayer;
@@ -1,30 +1,36 @@
1
1
  import { useState as k, useEffect as P } from "react";
2
2
  import { useMapContext as _ } from "../../../MapContext.js";
3
- import { MAP_LAYER_INCIDENTS as v } from "../../../constants.js";
4
- const L = 34, M = 38, g = 26, f = 31, w = (o) => `<svg width="${g}" height="${f}" xmlns="http://www.w3.org/2000/svg" baseProfile="tiny" viewBox="0 0 26 31">
3
+ import { MAP_LAYER_INCIDENTS as C } from "../../../constants.js";
4
+ const D = 34, I = 38, g = 26, f = 31, R = (c, p, h) => [
5
+ "https://data.traffic.hereapi.com/v7/incidents?in=",
6
+ `bbox:${c}`,
7
+ "&locationReferencing=shape",
8
+ h ? `&lang=${encodeURIComponent(h)}` : "",
9
+ `&apiKey=${p}`
10
+ ].join(""), L = (c) => `<svg width="${g}" height="${f}" xmlns="http://www.w3.org/2000/svg" baseProfile="tiny" viewBox="0 0 26 31">
5
11
  <path fill="#868686" d="M16.995 28.98c0 1.115-1.79 2.02-4 2.02s-4-.905-4-2.02c0-1.118 1.79-2.026 4-2.026s4 .907 4 2.025"/>
6
- <path fill="${o}" d="M1.702 17.693C.13 16.127.118 13.837 1.675 11.995l8.41-10.098c.772-.9 1.806-1.394 2.914-1.394 1.124 0 2.212.525 2.91 1.404l8.402 10.09c1.602 1.867 1.592 4.052-.027 5.693l-11.29 11.286L1.702 17.693z"/>
12
+ <path fill="${c}" d="M1.702 17.693C.13 16.127.118 13.837 1.675 11.995l8.41-10.098c.772-.9 1.806-1.394 2.914-1.394 1.124 0 2.212.525 2.91 1.404l8.402 10.09c1.602 1.867 1.592 4.052-.027 5.693l-11.29 11.286L1.702 17.693z"/>
7
13
  <path fill="#fff" d="M12.998 1.007c.97 0 1.91.445 2.516 1.213l8.41 10.1c1.375 1.602 1.494 3.503 0 5.016l-10.93 10.93-10.936-10.93c-1.392-1.384-1.39-3.374 0-5.016l8.41-10.1c.723-.84 1.642-1.213 2.53-1.213m0-1.007C11.74 0 10.57.555 9.703 1.563l-8.42 10.112c-1.732 2.047-1.708 4.61.063 6.374L12.28 28.976l.714.712.713-.713 10.93-10.93c1.8-1.82 1.818-4.324.055-6.383L16.288 1.576C15.514.596 14.278 0 12.998 0zM13.035 16.534c-.754 0-1.365.595-1.365 1.32 0 .73.613 1.326 1.365 1.326s1.363-.595 1.363-1.326c0-.725-.61-1.32-1.363-1.32zm0-1.332c.568 0 1.057-.448 1.088-.993l.365-5.916c.033-.548-.615-.996-1.455-.996-.832 0-1.49.448-1.453.996l.36 5.915c.034.544.526.992 1.095.992z"/>
8
- </svg>`, R = (o) => `<svg width="${g}" height="${f}" xmlns="http://www.w3.org/2000/svg">
14
+ </svg>`, N = (c) => `<svg width="${g}" height="${f}" xmlns="http://www.w3.org/2000/svg">
9
15
  <path fill="#878787" d="m 16.8,29.4 c 0,-1.1 -1.8,-2 -4,-2 -2.2,0 -4.01,0.9 -4.01,2 0,1.1 1.81,2 4.01,2 2.2,0 4,-0.9 4,-2"/>
10
- <path fill="${o}" d="m 24.1,17.8 c 1.6,-1.6 1.6,-3.8 0,-5.7 L 15.8,1.9 C 15,0.998 14,0.498 12.9,0.498 11.8,0.498 10.7,1.1 10,1.9 L 1.7,12.1 c -1.6,1.9 -1.6,4.1 0,5.7 L 12.9,29 24.1,17.8 z" stroke="#fff" stroke-width="1" />
16
+ <path fill="${c}" d="m 24.1,17.8 c 1.6,-1.6 1.6,-3.8 0,-5.7 L 15.8,1.9 C 15,0.998 14,0.498 12.9,0.498 11.8,0.498 10.7,1.1 10,1.9 L 1.7,12.1 c -1.6,1.9 -1.6,4.1 0,5.7 L 12.9,29 24.1,17.8 z" stroke="#fff" stroke-width="1" />
11
17
  <path d="m 18,15 0,0 c 0,-0.1 0,-0.2 0,-0.4 l 0,-0.2 c 0,-0.1 0,-0.2 0,-0.4 0,0 0,0 0,0 0.6,0 1.1,-0.4 1.1,-1 0,-0.5 -0.5,-1 -1,-1 -0.7,0 -1.1,0.5 -1.1,1 -0.1,0 -0.3,-0.1 -0.4,-0.1 l -0.6,0 -0.3,-0.5 C 15.2,11.6 14.3,11 13.3,11 L 18,11 17.2,9.6 C 17,9.3 16.7,9 16.3,9 L 12.8,9 C 12.4,9 12,9.3 11.8,9.6 L 11.1,11 9.8,11 C 9.7,11 9.6,11 9.5,11 9.2,11 9,10.9 9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 0 26 32" xmlns="http://www.w3.org/2000/svg">
18
+ </svg>`, M = (c) => `<svg width="${g}" height="${f}" viewBox="0 0 26 32" xmlns="http://www.w3.org/2000/svg">
13
19
  <g fill="none">
14
20
  <g>
15
21
  <path fill="#868686" d="M16.995 28.98c0 1.116-1.79 2.02-4 2.02s-4-.904-4-2.02c0-1.118 1.79-2.023 4-2.023 2.21-.004 4 .904 4 2.022" />
16
- <path fill="${o}" id="Shape" d="M1.675 11.995l8.41-10.098c.772-.9 1.806-1.394 2.914-1.394 1.124 0 2.212.525 2.91 1.404l8.402 10.09c1.602 1.867 1.592 4.052-.027 5.692l-11.29 11.286L1.702 17.693C.13 16.127.118 13.837 1.675 11.995z" />
22
+ <path fill="${c}" id="Shape" d="M1.675 11.995l8.41-10.098c.772-.9 1.806-1.394 2.914-1.394 1.124 0 2.212.525 2.91 1.404l8.402 10.09c1.602 1.867 1.592 4.052-.027 5.692l-11.29 11.286L1.702 17.693C.13 16.127.118 13.837 1.675 11.995z" />
17
23
  <path fill="#fff" id="Shape" d="M12.998 1.007c.97 0 1.91.445 2.516 1.213l8.41 10.1c1.375 1.602 1.494 3.503 0 5.016l-10.93 10.93-10.936-10.93c-1.392-1.384-1.39-3.374 0-5.016l8.41-10.1c.723-.84 1.642-1.213 2.53-1.213zm0-1.007C11.74 0 10.57.555 9.703 1.563l-8.42 10.112c-1.732 2.047-1.708 4.61.063 6.374L12.28 28.976l.714.713.713-.713 10.93-10.93c1.8-1.82 1.818-4.324.055-6.383L16.288 1.576C15.514.596 14.278 0 12.998 0z" />
18
24
  <path fill="#fff" d="M9 15h1.5v3.8H9zM16 15h1.5v3.8H16z" />
19
25
  <path fill="#fff" id="Shape" d="M20.01 13.965c0 .276-.225.5-.5.5h-13c-.275 0-.5-.224-.5-.5v-2.637c0-.276.225-.5.5-.5h13c.275 0 .5.224.5.5v2.637z" />
20
26
  <path fill="#D5232F" d="M9.565 11.33l-2.638 2.634h3.107l2.635-2.635H9.564zM16.004 11.33l-2.634 2.634h3.105l2.634-2.635h-3.106z" />
21
27
  </g>
22
28
  </g>
23
- </svg>`, N = (o) => `<svg width="${g}" height="${f}" xmlns="http://www.w3.org/2000/svg">
29
+ </svg>`, A = (c) => `<svg width="${g}" height="${f}" xmlns="http://www.w3.org/2000/svg">
24
30
  <path fill="#878787" d="m 16.8,29.4 c 0,-1.1 -1.8,-2 -4,-2 -2.2,0 -4.01,0.9 -4.01,2 0,1.1 1.81,2 4.01,2 2.2,0 4,-0.9 4,-2" />
25
- <path fill="${o}" stroke="#fff" stroke-width="1" d="m 24.1,17.8 c 1.6,-1.6 1.6,-3.8 0,-5.7 L 15.8,1.9 C 15,0.998 14,0.498 12.9,0.498 11.8,0.498 10.7,1.1 10,1.9 L 1.7,12.1 c -1.6,1.9 -1.6,4.1 0,5.7 L 12.9,29 24.1,17.8 z" />
31
+ <path fill="${c}" stroke="#fff" stroke-width="1" d="m 24.1,17.8 c 1.6,-1.6 1.6,-3.8 0,-5.7 L 15.8,1.9 C 15,0.998 14,0.498 12.9,0.498 11.8,0.498 10.7,1.1 10,1.9 L 1.7,12.1 c -1.6,1.9 -1.6,4.1 0,5.7 L 12.9,29 24.1,17.8 z" />
26
32
  <path fill="#ffffff" d="m 9.24,13.2 -3.7,6.8 1.3,0 2.8,-5.1 1.36,1.5 0,3.6 1.1,0 0,-4 -1.4,-1.6 -1.46,-1.2 z M 14.2,9.5 c 0.7,0 1.3,-0.5 1.3,-1.21 0,-0.7 -0.6,-1.2 -1.3,-1.2 -0.7,0 -1.2,0.5 -1.2,1.2 0,0.71 0.5,1.21 1.2,1.21 m -4.46,0.5 1.06,0 -0.96,2.1 -1,-0.8 0.9,-1.3 z m 2.56,4 -1,-0.7 1,-1.9 0,2.6 z m 6.9,1.7 c -0.4,-0.5 -1.5,-1.1 -2.3,0 -0.2,0.3 -0.6,0.7 -0.9,1.2 l -2.7,-2.1 0,-5 -0.8,-0.7 -3.26,0 -1.5,2.3 7.86,6 C 14.7,18.6 13.8,20 13.8,20 l 6,0 1.5,-1.6 c 0,0 -1.7,-2.2 -2.1,-2.7" />
27
- </svg>`, A = (o) => `<svg xmlns="http://www.w3.org/2000/svg" width="${L}" height="${M}" viewBox="0 0 40 44">
33
+ </svg>`, O = (c) => `<svg xmlns="http://www.w3.org/2000/svg" width="${D}" height="${I}" viewBox="0 0 40 44">
28
34
  <g opacity=".25">
29
35
  <path fill="#4B4B4C" d="M20.498 42.5C12.778 42.5 6.5 39.584 6.5 36s6.28-6.5 13.998-6.5c7.72 0 14.002 2.916 14.002 6.5s-6.28 6.5-14.002 6.5z" />
30
36
  <path d="M20.498 30C28.574 30 34 33.104 34 36s-5.426 6-13.502 6C12.424 42 7 38.896 7 36s5.424-6 13.498-6m0-1C12.492 29 6 32.113 6 36s6.492 7 14.498 7C28.508 43 35 39.887 35 36s-6.49-7-14.502-7z" />
@@ -37,13 +43,13 @@ const L = 34, M = 38, g = 26, f = 31, w = (o) => `<svg width="${g}" height="${f}
37
43
  <path fill="#fff" d="M19.998 1c-1.453 0-2.803.64-3.803 1.803L6.48 14.47c-2 2.363-1.97 5.32.072 7.355L19 35l1 1 1-1 12.426-13.176c2.076-2.1 2.1-4.988.064-7.365L23.793 2.817C22.9 1.688 21.473 1 19.998 1z" />
38
44
  <path fill="#646469" d="M19.998 2.162c1.12 0 2.2.514 2.902 1.398l9.703 11.653c1.588 1.85 1.725 4.044 0 5.79L20 34.5 7.375 21.004c-1.607-1.598-1.605-3.895 0-5.79l9.703-11.65c.834-.972 1.895-1.402 2.92-1.402" />
39
45
  <path fill="none" d="M18.333 12.667H45.75v10.736H18.333z" />
40
- <text transform="translate(20 23)" fill="#fff" font-family="sans-serif" font-size="14" color="#fff" font-weight="600" text-anchor="middle">${o}</text>
46
+ <text transform="translate(20 23)" fill="#fff" font-family="sans-serif" font-size="14" color="#fff" font-weight="600" text-anchor="middle">${c}</text>
41
47
  </svg>`, G = () => {
42
- const { api: o, language: D, onIncidentsChange: I } = _(), l = o.map, [m, y] = k([]);
48
+ const { api: c, language: p, onIncidentsChange: h } = _(), l = c.map, [v, y] = k([]);
43
49
  P(() => {
44
- let e, c;
50
+ let e, i;
45
51
  if (l) {
46
- const i = new H.clustering.Provider(m, {
52
+ const o = new H.clustering.Provider(v, {
47
53
  min: 1,
48
54
  max: 21,
49
55
  clusteringOptions: {
@@ -52,7 +58,7 @@ const L = 34, M = 38, g = 26, f = 31, w = (o) => `<svg width="${g}" height="${f}
52
58
  },
53
59
  theme: {
54
60
  getClusterPresentation(n) {
55
- const t = A(n.getWeight()), a = L, s = M, r = new H.map.Icon(t, {
61
+ const t = O(n.getWeight()), a = D, s = I, r = new H.map.Icon(t, {
56
62
  size: { w: a, h: s },
57
63
  anchor: { x: a / 2, y: s / 2 }
58
64
  }), d = new H.map.Marker(n.getPosition(), {
@@ -65,7 +71,7 @@ const L = 34, M = 38, g = 26, f = 31, w = (o) => `<svg width="${g}" height="${f}
65
71
  return d.setData(n), d;
66
72
  },
67
73
  getNoisePresentation(n) {
68
- const t = B(n), a = g, s = f, r = new H.map.Icon(t, {
74
+ const t = b(n), a = g, s = f, r = new H.map.Icon(t, {
69
75
  size: { w: a, h: s },
70
76
  anchor: { x: a / 2, y: s }
71
77
  }), d = new H.map.Marker(n.getPosition(), {
@@ -73,55 +79,50 @@ const L = 34, M = 38, g = 26, f = 31, w = (o) => `<svg width="${g}" height="${f}
73
79
  // Use min zoom from a noise point to show it correctly at certain zoom levels:
74
80
  min: n.getMinZoom()
75
81
  });
76
- return d.setData(n), d.addEventListener("pointerenter", (p) => {
77
- const E = p.target.getData().getData().tooltipContent, S = p.target.getData().getPosition(), h = l.geoToScreen(S);
78
- h.x += 0, h.y += -f;
79
- const b = new H.ui.InfoBubble(l.screenToGeo(h.x, h.y), {
80
- content: E
82
+ return d.setData(n), d.addEventListener("pointerenter", (u) => {
83
+ const B = u.target.getData().getData().tooltipContent, E = u.target.getData().getPosition(), m = l.geoToScreen(E);
84
+ m.x += 0, m.y += -f;
85
+ const S = new H.ui.InfoBubble(l.screenToGeo(m.x, m.y), {
86
+ content: B
81
87
  });
82
- o.ui?.addBubble(b);
83
- }), d.addEventListener("pointerleave", (p) => {
84
- u();
88
+ c.ui?.addBubble(S);
89
+ }), d.addEventListener("pointerleave", (u) => {
90
+ w();
85
91
  }), d;
86
92
  }
87
93
  }
88
94
  });
89
- c = () => {
90
- u(), i.setDataPoints(m);
95
+ i = () => {
96
+ w(), o.setDataPoints(v);
91
97
  const n = l.getViewModel().getLookAtData().bounds?.getBoundingBox(), t = l.getViewModel().getLookAtData().position;
92
- n && t && z(i, n, t, D);
93
- }, c(), l?.addEventListener("mapviewchangeend", c), e = new H.map.layer.ObjectLayer(i), l.addLayer(e), console.log(`add layer - ${v}`);
98
+ n && t && z(o, n, t, p);
99
+ }, i(), l?.addEventListener("mapviewchangeend", i), e = new H.map.layer.ObjectLayer(o), l.addLayer(e), console.log(`add layer - ${C}`);
94
100
  }
95
101
  return () => {
96
- e && (o.map?.removeLayer(e), e.dispose(), console.log(`remove layer - ${v}`)), c && l?.removeEventListener("mapviewchangeend", c);
102
+ e && (c.map?.removeLayer(e), e.dispose(), console.log(`remove layer - ${C}`)), i && l?.removeEventListener("mapviewchangeend", i);
97
103
  };
98
- }, [o.map]);
99
- const z = (e, c, i, n) => {
104
+ }, [c.map, p]);
105
+ const z = (e, i, o, n) => {
100
106
  if (l && l.getZoom() < 11) {
101
107
  console.log("Too much incidents to show, please zoom in");
102
108
  return;
103
109
  }
104
- const a = [
105
- "https://data.traffic.hereapi.com/v7/incidents?in=",
106
- `bbox:${`${c.getLeft()},${c.getBottom()},${c.getRight()},${c.getTop()}`}`,
107
- "&locationReferencing=shape",
108
- `&apiKey=${o.credentials?.apikey}`
109
- ].join("");
110
+ const t = `${i.getLeft()},${i.getBottom()},${i.getRight()},${i.getTop()}`, a = R(t, c.credentials?.apikey, n);
110
111
  fetch(a).then((s) => s.json()).then((s) => {
111
112
  if (s.results) {
112
113
  const r = $(s, n);
113
114
  e.setDataPoints(r), y(r);
114
115
  }
115
116
  });
116
- }, $ = (e, c) => {
117
- const i = [], n = {
117
+ }, $ = (e, i) => {
118
+ const o = [], n = {
118
119
  sourceUpdated: e.sourceUpdated,
119
120
  results: []
120
121
  };
121
122
  return e.results.forEach((t) => {
122
123
  const a = t.location.shape.links[0].points[0].lat, s = t.location.shape.links[0].points[0].lng, r = {
123
124
  id: t.incidentDetails.id,
124
- tooltipContent: x(t, c),
125
+ tooltipContent: x(t, i),
125
126
  criticality: t.incidentDetails.criticality,
126
127
  description: t.incidentDetails.description,
127
128
  summary: t.incidentDetails.summary,
@@ -135,20 +136,20 @@ const L = 34, M = 38, g = 26, f = 31, w = (o) => `<svg width="${g}" height="${f}
135
136
  lng: s
136
137
  }
137
138
  };
138
- n.results.push(r), i.push(new H.clustering.DataPoint(a, s, 1, r));
139
- }), I(n), i;
140
- }, x = (e, c) => {
141
- const { comment: i = "", description: n, startTime: t, endTime: a } = e.incidentDetails;
139
+ n.results.push(r), o.push(new H.clustering.DataPoint(a, s, 1, r));
140
+ }), h(n), o;
141
+ }, x = (e, i) => {
142
+ const { comment: o = "", description: n, startTime: t, endTime: a } = e.incidentDetails;
142
143
  return `
143
- <div class="text-size-12 line-height-16 margin-right-5 ${i ? "min-width-250" : "min-width-150"}">
144
+ <div class="text-size-12 line-height-16 margin-right-5 ${o ? "min-width-250" : "min-width-150"}">
144
145
  <div class="text-medium">${n.value}</div>
145
146
  <div class="margin-top-5 text-color-dark">
146
- ${new Intl.DateTimeFormat(c).format(Date.parse(t))} -
147
- ${new Intl.DateTimeFormat(c).format(Date.parse(a))}
147
+ ${new Intl.DateTimeFormat(i).format(Date.parse(t))} -
148
+ ${new Intl.DateTimeFormat(i).format(Date.parse(a))}
148
149
  </div>
149
- <hr class="${i ? "margin-y-10" : "display-none"}" />
150
+ <hr class="${o ? "margin-y-10" : "display-none"}" />
150
151
  <div>
151
- ${i}
152
+ ${o}
152
153
  </div>
153
154
  </div>
154
155
  `;
@@ -163,32 +164,33 @@ const L = 34, M = 38, g = 26, f = 31, w = (o) => `<svg width="${g}" height="${f}
163
164
  default:
164
165
  return "#000";
165
166
  }
166
- }, B = (e) => {
167
- const c = e.getData().type, i = T(e);
168
- switch (c) {
167
+ }, b = (e) => {
168
+ const i = e.getData().type, o = T(e);
169
+ switch (i) {
169
170
  case "congestion":
170
- return R(i);
171
+ return N(o);
171
172
  case "roadClosure":
172
- return C(i);
173
+ return M(o);
173
174
  case "construction":
174
- return N(i);
175
+ return A(o);
175
176
  case "other":
176
- return e.getData().roadClosed ? C(i) : w(i);
177
+ return e.getData().roadClosed ? M(o) : L(o);
177
178
  default:
178
- return w(i);
179
+ return L(o);
179
180
  }
180
- }, u = () => {
181
- o.ui?.getBubbles().forEach((e) => {
182
- o.ui?.removeBubble(e);
181
+ }, w = () => {
182
+ c.ui?.getBubbles().forEach((e) => {
183
+ c.ui?.removeBubble(e);
183
184
  });
184
185
  };
185
186
  return null;
186
187
  };
187
188
  export {
188
- M as CLUSTER_ICON_HEIGHT,
189
- L as CLUSTER_ICON_WIDTH,
189
+ I as CLUSTER_ICON_HEIGHT,
190
+ D as CLUSTER_ICON_WIDTH,
190
191
  f as MARKER_ICON_HEIGHT,
191
192
  g as MARKER_ICON_WIDTH,
193
+ R as buildTrafficIncidentsUrl,
192
194
  G as default
193
195
  };
194
196
  //# sourceMappingURL=IncidentsLayer.js.map