@collabdt/core 0.12.0 → 0.12.2
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/dist/core/components/viewers/Viewer.d.ts.map +1 -1
- package/dist/core/components/viewers/Viewer.js +7 -10
- package/dist/core/components/viewers/Viewer.js.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/buildingLocationParams.d.ts +1 -0
- package/dist/core/components/viewers/bim/src/lib/buildingLocationParams.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/buildingLocationParams.js +10 -2
- package/dist/core/components/viewers/bim/src/lib/buildingLocationParams.js.map +1 -1
- package/dist/core/components/viewers/bim/utils/setCameraLookAt.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/utils/setCameraLookAt.js +13 -14
- package/dist/core/components/viewers/bim/utils/setCameraLookAt.js.map +1 -1
- package/dist/core/components/viewers/map/MapViewer.d.ts.map +1 -1
- package/dist/core/components/viewers/map/MapViewer.js +11 -8
- package/dist/core/components/viewers/map/MapViewer.js.map +1 -1
- package/dist/core/components/viewers/map/src/Geocoder.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/Geocoder.js +23 -20
- package/dist/core/components/viewers/map/src/Geocoder.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/CountryLayer/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/CountryLayer/index.js +7 -6
- package/dist/core/components/viewers/map/src/MapLayers/src/CountryLayer/index.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/LocationSettings.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/LocationSettings.js +12 -32
- package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/LocationSettings.js.map +1 -1
- package/dist/core/components/viewers/map/src/tools/shareMapTool.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/tools/shareMapTool.js +24 -14
- package/dist/core/components/viewers/map/src/tools/shareMapTool.js.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoder.d.ts +1 -0
- package/dist/core/components/viewers/map/utils/geocoder.d.ts.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoder.js +5 -0
- package/dist/core/components/viewers/map/utils/geocoder.js.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoding/adapters.d.ts +2 -0
- package/dist/core/components/viewers/map/utils/geocoding/adapters.d.ts.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoding/adapters.js +8 -1
- package/dist/core/components/viewers/map/utils/geocoding/adapters.js.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoding/index.d.ts +3 -0
- package/dist/core/components/viewers/map/utils/geocoding/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoding/index.js +20 -3
- package/dist/core/components/viewers/map/utils/geocoding/index.js.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoding/osm.d.ts +2 -0
- package/dist/core/components/viewers/map/utils/geocoding/osm.d.ts.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoding/osm.js +32 -1
- package/dist/core/components/viewers/map/utils/geocoding/osm.js.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoding/pelias.d.ts +2 -0
- package/dist/core/components/viewers/map/utils/geocoding/pelias.d.ts.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoding/pelias.js +30 -1
- package/dist/core/components/viewers/map/utils/geocoding/pelias.js.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoding/placeSearch.d.ts +17 -0
- package/dist/core/components/viewers/map/utils/geocoding/placeSearch.d.ts.map +1 -0
- package/dist/core/components/viewers/map/utils/geocoding/placeSearch.js +26 -0
- package/dist/core/components/viewers/map/utils/geocoding/placeSearch.js.map +1 -0
- package/dist/core/components/viewers/map/utils/urlLocation/locationParams.d.ts +38 -0
- package/dist/core/components/viewers/map/utils/urlLocation/locationParams.d.ts.map +1 -0
- package/dist/core/components/viewers/map/utils/urlLocation/locationParams.js +91 -0
- package/dist/core/components/viewers/map/utils/urlLocation/locationParams.js.map +1 -0
- package/dist/core/components/viewers/map/utils/urlLocation/locationTarget.d.ts +25 -0
- package/dist/core/components/viewers/map/utils/urlLocation/locationTarget.d.ts.map +1 -0
- package/dist/core/components/viewers/map/utils/urlLocation/locationTarget.js +71 -0
- package/dist/core/components/viewers/map/utils/urlLocation/locationTarget.js.map +1 -0
- package/dist/core/components/viewers/map/utils/urlLocation/resolveLocationTarget.d.ts +20 -0
- package/dist/core/components/viewers/map/utils/urlLocation/resolveLocationTarget.d.ts.map +1 -0
- package/dist/core/components/viewers/map/utils/urlLocation/resolveLocationTarget.js +103 -0
- package/dist/core/components/viewers/map/utils/urlLocation/resolveLocationTarget.js.map +1 -0
- package/dist/core/components/viewers/map/utils/urlLocation/useUrlFlyTo.d.ts +4 -0
- package/dist/core/components/viewers/map/utils/urlLocation/useUrlFlyTo.d.ts.map +1 -0
- package/dist/core/components/viewers/map/utils/urlLocation/useUrlFlyTo.js +72 -0
- package/dist/core/components/viewers/map/utils/urlLocation/useUrlFlyTo.js.map +1 -0
- package/dist/core/hooks/useShareUrl.d.ts.map +1 -1
- package/dist/core/hooks/useShareUrl.js +5 -9
- package/dist/core/hooks/useShareUrl.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Viewer.d.ts","sourceRoot":"","sources":["../../../../src/core/components/viewers/Viewer.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"Viewer.d.ts","sourceRoot":"","sources":["../../../../src/core/components/viewers/Viewer.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAiB9B,OAAO,KAAK,EAAE,YAAY,EAAa,MAAM,qBAAqB,CAAA;AAqClE,UAAU,WAAW;IACnB,YAAY,EAAE,YAAY,CAAA;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,wBAAgB,MAAM,CAAC,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,WAAW,EAAE,kBAAkB,EAAE,WAAW,EAAE,EAAE,WAAW,qBAuIhJ"}
|
|
@@ -14,6 +14,7 @@ import { UserSettings } from "../settings";
|
|
|
14
14
|
import { Toolbar } from "../Toolbar";
|
|
15
15
|
import { UploadProgressToasts } from "../ui/FilesManager/src/UploadProgressBar";
|
|
16
16
|
import { SidebarTrigger } from "../ui/Sidebar";
|
|
17
|
+
import { withBuildingId } from "./bim/src/lib/buildingLocationParams";
|
|
17
18
|
import { MapViewer } from "./map/MapViewer";
|
|
18
19
|
import { isViewerAllowed } from "./viewerAccess";
|
|
19
20
|
const BimViewer = dynamic(
|
|
@@ -55,11 +56,9 @@ function Viewer({ organization, minioBaseUrl, martinBaseUrl, pointcloudApiUrl, m
|
|
|
55
56
|
const validViewer = isViewerValid ? viewer : ViewerNames.map;
|
|
56
57
|
React.useEffect(() => {
|
|
57
58
|
if (isMounted && !isViewerValid && viewer !== ViewerNames.map) {
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
newSearchParams.set("buildingId", String(building.id));
|
|
62
|
-
}
|
|
59
|
+
const current = new URLSearchParams(searchParams.toString());
|
|
60
|
+
current.delete("viewer");
|
|
61
|
+
const newSearchParams = (building == null ? void 0 : building.id) ? withBuildingId(current, building.id) : current;
|
|
63
62
|
router.replace(`${pathname}?${newSearchParams.toString()}`, { scroll: false });
|
|
64
63
|
}
|
|
65
64
|
}, [isMounted, isViewerValid, viewer, searchParams, pathname, router, building == null ? void 0 : building.id]);
|
|
@@ -83,11 +82,9 @@ function Viewer({ organization, minioBaseUrl, martinBaseUrl, pointcloudApiUrl, m
|
|
|
83
82
|
return;
|
|
84
83
|
}
|
|
85
84
|
isUpdatingRef.current = true;
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
newSearchParams.set("buildingId", String(building.id));
|
|
90
|
-
}
|
|
85
|
+
const current = new URLSearchParams(searchParams.toString());
|
|
86
|
+
current.set("viewer", currentViewer);
|
|
87
|
+
const newSearchParams = (building == null ? void 0 : building.id) ? withBuildingId(current, building.id) : current;
|
|
91
88
|
router.replace(`${pathname}?${newSearchParams.toString()}`, { scroll: false });
|
|
92
89
|
setTimeout(() => {
|
|
93
90
|
isUpdatingRef.current = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/components/viewers/Viewer.tsx"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\n// Dependencies\nimport { Loader2 } from 'lucide-react'\nimport dynamic from 'next/dynamic'\nimport { useSearchParams, useRouter, usePathname } from 'next/navigation'\nimport * as React from 'react'\n\nimport { parsePluginViewerKey } from '../../plugins/host/pluginViewerKey'\nimport { BuildingsContext, MenusContext } from '../../store'\nimport { ViewerNames } from '../../types'\n\n// Deep import, not the ui barrel: the barrel drags heavy modules into the eager map bundle.\nimport { switchLanguage } from '../../utils/utils'\nimport { UserSettings } from '../settings'\nimport { Toolbar } from '../Toolbar'\nimport { UploadProgressToasts } from '../ui/FilesManager/src/UploadProgressBar'\nimport { SidebarTrigger } from '../ui/Sidebar'\n\nimport { MapViewer } from './map/MapViewer'\nimport { isViewerAllowed } from './viewerAccess'\n\nimport type { Organization, ViewerKey } from '../../types/dbTypes'\n\n// Code-split: map-only sessions must not pay for @thatopen or the Potree stack.\nconst BimViewer = dynamic(\n () => import('./bim/BimViewer').then(m => ({ default: m.BimViewer })),\n { ssr: false, loading: () => <ViewerLoadingFallback label=\"Loading BIM viewer…\" /> },\n)\n\n// DataMenu reaches BimViewer through FilePreview, so a static import undoes the split above.\nconst PluginsManager = dynamic(\n () => import('./plugins/PluginsManager').then(m => ({ default: m.PluginsManager })),\n { ssr: false, loading: () => <ViewerLoadingFallback label=\"Loading plugins…\" /> },\n)\n\nconst DataMenu = dynamic(\n () => import('./Data/DataMenu').then(m => ({ default: m.DataMenu })),\n { ssr: false, loading: () => <ViewerLoadingFallback label=\"Loading data…\" /> },\n)\n\n// Lazy too, or every plugin's page code lands in the eager bundle for every user.\nconst PluginDataPageHost = dynamic(\n () => import('../../plugins/host/PluginDataPageHost').then(m => ({ default: m.PluginDataPageHost })),\n { ssr: false, loading: () => <ViewerLoadingFallback label=\"Loading page…\" /> },\n)\n\n// Matches BimLoadingState using only Tailwind tokens, so the eager bundle stays light.\nfunction ViewerLoadingFallback({ label }: { label: string }) {\n return (\n <div className=\"absolute inset-0 z-10 flex items-center justify-center bg-background/50 backdrop-blur-[1px]\">\n <div className=\"flex items-center gap-3 rounded-md border border-border bg-card px-5 py-4 shadow-sm\">\n <Loader2 className=\"h-5 w-5 animate-spin text-muted-foreground\" />\n <span className=\"text-foreground text-base font-medium font-['Inter'] leading-7\">{label}</span>\n </div>\n </div>\n )\n}\n\ninterface ViewerProps {\n organization: Organization\n minioBaseUrl?: string\n martinBaseUrl?: string\n pointcloudApiUrl?: string\n maptilerKey?: string\n geocodeEarthApiKey?: string\n geocoderUrl?: string\n}\n\nexport function Viewer({ organization, minioBaseUrl, martinBaseUrl, pointcloudApiUrl, maptilerKey, geocodeEarthApiKey, geocoderUrl }: ViewerProps) {\n\n const searchParams = useSearchParams()\n const viewer = (searchParams.get('viewer') as ViewerKey) || ViewerNames.map\n\n const { dispatch: menusDispatch, state: menusState } = React.useContext(MenusContext)\n const { state: buildingState } = React.useContext(BuildingsContext)\n // const { dispatch: appConfigDispatch } = React.useContext(AppConfigContext)\n const { building } = buildingState.buildings\n const { currentViewer } = menusState.menus\n const router = useRouter()\n const pathname = usePathname()\n const [isMounted, setIsMounted] = React.useState(false)\n\n // Use a ref to track if we're currently updating -> prevent circular updates\n const isUpdatingRef = React.useRef(false)\n\n const { appContent } = organization\n\n const pluginPage = parsePluginViewerKey(viewer)\n const isViewerValid = isViewerAllowed(viewer, appContent)\n\n // Use default viewer (map) if current viewer is not valid\n const validViewer = isViewerValid ? viewer : ViewerNames.map\n\n // Update URL if viewer was not available for the organization\n React.useEffect(() => {\n if (isMounted && !isViewerValid && viewer !== ViewerNames.map) {\n const newSearchParams = new URLSearchParams(searchParams.toString())\n newSearchParams.delete('viewer')\n if (building?.id) {\n newSearchParams.set('buildingId', String(building.id))\n }\n router.replace(`${pathname}?${newSearchParams.toString()}`, { scroll: false })\n }\n }, [isMounted, isViewerValid, viewer, searchParams, pathname, router, building?.id])\n\n // On first mount, respond to URL\n React.useEffect(() => {\n if (!isMounted) {\n menusDispatch({\n type: 'SET_VIEWER',\n payload: { currentViewer: validViewer },\n })\n setIsMounted(true)\n }\n }, [isMounted, validViewer, menusDispatch])\n\n React.useEffect(() => {\n if (!organization) return\n const defaultLanguage = organization.languages?.[0] || 'En'\n if (defaultLanguage) void switchLanguage(defaultLanguage)\n }, [organization])\n\n // Handle context changes (from sidebar, HeaderButtons, etc.)\n React.useEffect(() => {\n if (!isMounted || !currentViewer || currentViewer === validViewer || isUpdatingRef.current) {\n return\n }\n\n isUpdatingRef.current = true\n\n // Create URLSearchParams to preserve existing search params\n\n const newSearchParams = new URLSearchParams(searchParams.toString())\n newSearchParams.set('viewer', currentViewer)\n if (building?.id) {\n newSearchParams.set('buildingId', String(building.id))\n }\n\n\n router.replace(`${pathname}?${newSearchParams.toString()}`, { scroll: false })\n\n // Reset the flag after a brief delay to allow the navigation to complete\n setTimeout(() => {\n isUpdatingRef.current = false\n }, 100)\n }, [currentViewer, isMounted, pathname, router, viewer, searchParams])\n\n // Handle URL changes (direct navigation)\n React.useEffect(() => {\n if (isMounted && currentViewer !== validViewer && !isUpdatingRef.current) {\n isUpdatingRef.current = true\n\n menusDispatch({\n type: 'SET_VIEWER',\n payload: { currentViewer: validViewer },\n })\n\n // Reset the flag after a brief delay\n setTimeout(() => {\n isUpdatingRef.current = false\n }, 100)\n }\n }, [validViewer, menusDispatch, isMounted, currentViewer])\n\n // Null while a plugin page shows, so the branches below stay exhaustive over ViewerNames.\n const builtInViewer = pluginPage ? null : (validViewer as ViewerNames)\n\n const selectedViewer = (\n <>\n {builtInViewer !== null\n && [ViewerNames.map, ViewerNames.bim].includes(builtInViewer)\n && <SidebarTrigger />}\n <div style={{ height: '100%', width: '100%', position: 'relative' }}>\n <div style={{ display: builtInViewer === ViewerNames.map ? 'block' : 'none', width: '100%', height: '100%' }}>\n <MapViewer organization={organization} maptilerKey={maptilerKey} />\n </div>\n {builtInViewer === ViewerNames.bim && <BimViewer pointcloudApiUrl={pointcloudApiUrl} />}\n {builtInViewer !== null\n && [ViewerNames.buildings, ViewerNames.sites, ViewerNames.files, ViewerNames.land, ViewerNames.infrastructure, ViewerNames.users].includes(builtInViewer) && (\n <DataMenu currentViewer={builtInViewer} organization={organization} geocodeEarthApiKey={geocodeEarthApiKey} geocoderUrl={geocoderUrl} />\n )}\n {/* `plugins` used to route through DataMenu, which rendered nothing:\n VIEWER_CONFIG gives it no dataType. It has its own page now. */}\n {builtInViewer === ViewerNames.extensions && (\n <div className=\"h-full w-full overflow-y-auto\">\n <PluginsManager />\n </div>\n )}\n {builtInViewer === ViewerNames.settings && (\n <UserSettings minioBaseUrl={minioBaseUrl} />\n )}\n {pluginPage && (\n <div className=\"h-full w-full overflow-y-auto\">\n <PluginDataPageHost viewer={validViewer} />\n </div>\n )}\n </div>\n </>\n )\n\n return (\n <>\n {selectedViewer}\n <Toolbar viewer={validViewer} minioBaseUrl={minioBaseUrl} martinBaseUrl={martinBaseUrl} organization={organization} geocodeEarthApiKey={geocodeEarthApiKey} geocoderUrl={geocoderUrl} />\n <UploadProgressToasts />\n </>\n )\n}"],"mappings":";AA8B+B,SA8I3B,UA9I2B,KAwBzB,YA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BAAC,kBAAe;AAAA,IACrB,qBAAC,SAAI,OAAO,EAAE,QAAQ,QAAQ,OAAO,QAAQ,UAAU,WAAW,GAChE;AAAA,0BAAC,SAAI,OAAO,EAAE,SAAS,kBAAkB,YAAY,MAAM,UAAU,QAAQ,OAAO,QAAQ,QAAQ,OAAO,GACzG,8BAAC,aAAU,cAA4B,aAA0B,GACnE;AAAA,MACC,kBAAkB,YAAY,OAAO,oBAAC,aAAU,kBAAoC;AAAA,MACpF,kBAAkB,QACd,CAAC,YAAY,WAAW,YAAY,OAAO,YAAY,OAAO,YAAY,MAAM,YAAY,gBAAgB,YAAY,KAAK,EAAE,SAAS,aAAa,KACxJ,oBAAC,YAAS,eAAe,eAAe,cAA4B,oBAAwC,aAA0B;AAAA,MAIvI,kBAAkB,YAAY,cAC7B,oBAAC,SAAI,WAAU,iCACb,8BAAC,kBAAe,GAClB;AAAA,MAED,kBAAkB,YAAY,YAC7B,oBAAC,gBAAa,cAA4B;AAAA,MAE3C,cACC,oBAAC,SAAI,WAAU,iCACb,8BAAC,sBAAmB,QAAQ,aAAa,GAC3C;AAAA,OAEJ;AAAA,KACF;AAGF,SACE,iCACG;AAAA;AAAA,IACD,oBAAC,WAAQ,QAAQ,aAAa,cAA4B,eAA8B,cAA4B,oBAAwC,aAA0B;AAAA,IACtL,oBAAC,wBAAqB;AAAA,KACxB;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/components/viewers/Viewer.tsx"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\n// Dependencies\nimport { Loader2 } from 'lucide-react'\nimport dynamic from 'next/dynamic'\nimport { useSearchParams, useRouter, usePathname } from 'next/navigation'\nimport * as React from 'react'\n\nimport { parsePluginViewerKey } from '../../plugins/host/pluginViewerKey'\nimport { BuildingsContext, MenusContext } from '../../store'\nimport { ViewerNames } from '../../types'\n\n// Deep import, not the ui barrel: the barrel drags heavy modules into the eager map bundle.\nimport { switchLanguage } from '../../utils/utils'\nimport { UserSettings } from '../settings'\nimport { Toolbar } from '../Toolbar'\nimport { UploadProgressToasts } from '../ui/FilesManager/src/UploadProgressBar'\nimport { SidebarTrigger } from '../ui/Sidebar'\n\nimport { withBuildingId } from './bim/src/lib/buildingLocationParams'\nimport { MapViewer } from './map/MapViewer'\nimport { isViewerAllowed } from './viewerAccess'\n\nimport type { Organization, ViewerKey } from '../../types/dbTypes'\n\n// Code-split: map-only sessions must not pay for @thatopen or the Potree stack.\nconst BimViewer = dynamic(\n () => import('./bim/BimViewer').then(m => ({ default: m.BimViewer })),\n { ssr: false, loading: () => <ViewerLoadingFallback label=\"Loading BIM viewer…\" /> },\n)\n\n// DataMenu reaches BimViewer through FilePreview, so a static import undoes the split above.\nconst PluginsManager = dynamic(\n () => import('./plugins/PluginsManager').then(m => ({ default: m.PluginsManager })),\n { ssr: false, loading: () => <ViewerLoadingFallback label=\"Loading plugins…\" /> },\n)\n\nconst DataMenu = dynamic(\n () => import('./Data/DataMenu').then(m => ({ default: m.DataMenu })),\n { ssr: false, loading: () => <ViewerLoadingFallback label=\"Loading data…\" /> },\n)\n\n// Lazy too, or every plugin's page code lands in the eager bundle for every user.\nconst PluginDataPageHost = dynamic(\n () => import('../../plugins/host/PluginDataPageHost').then(m => ({ default: m.PluginDataPageHost })),\n { ssr: false, loading: () => <ViewerLoadingFallback label=\"Loading page…\" /> },\n)\n\n// Matches BimLoadingState using only Tailwind tokens, so the eager bundle stays light.\nfunction ViewerLoadingFallback({ label }: { label: string }) {\n return (\n <div className=\"absolute inset-0 z-10 flex items-center justify-center bg-background/50 backdrop-blur-[1px]\">\n <div className=\"flex items-center gap-3 rounded-md border border-border bg-card px-5 py-4 shadow-sm\">\n <Loader2 className=\"h-5 w-5 animate-spin text-muted-foreground\" />\n <span className=\"text-foreground text-base font-medium font-['Inter'] leading-7\">{label}</span>\n </div>\n </div>\n )\n}\n\ninterface ViewerProps {\n organization: Organization\n minioBaseUrl?: string\n martinBaseUrl?: string\n pointcloudApiUrl?: string\n maptilerKey?: string\n geocodeEarthApiKey?: string\n geocoderUrl?: string\n}\n\nexport function Viewer({ organization, minioBaseUrl, martinBaseUrl, pointcloudApiUrl, maptilerKey, geocodeEarthApiKey, geocoderUrl }: ViewerProps) {\n\n const searchParams = useSearchParams()\n const viewer = (searchParams.get('viewer') as ViewerKey) || ViewerNames.map\n\n const { dispatch: menusDispatch, state: menusState } = React.useContext(MenusContext)\n const { state: buildingState } = React.useContext(BuildingsContext)\n // const { dispatch: appConfigDispatch } = React.useContext(AppConfigContext)\n const { building } = buildingState.buildings\n const { currentViewer } = menusState.menus\n const router = useRouter()\n const pathname = usePathname()\n const [isMounted, setIsMounted] = React.useState(false)\n\n // Use a ref to track if we're currently updating -> prevent circular updates\n const isUpdatingRef = React.useRef(false)\n\n const { appContent } = organization\n\n const pluginPage = parsePluginViewerKey(viewer)\n const isViewerValid = isViewerAllowed(viewer, appContent)\n\n // Use default viewer (map) if current viewer is not valid\n const validViewer = isViewerValid ? viewer : ViewerNames.map\n\n // Update URL if viewer was not available for the organization\n React.useEffect(() => {\n if (isMounted && !isViewerValid && viewer !== ViewerNames.map) {\n const current = new URLSearchParams(searchParams.toString())\n current.delete('viewer')\n const newSearchParams = building?.id ? withBuildingId(current, building.id) : current\n router.replace(`${pathname}?${newSearchParams.toString()}`, { scroll: false })\n }\n }, [isMounted, isViewerValid, viewer, searchParams, pathname, router, building?.id])\n\n // On first mount, respond to URL\n React.useEffect(() => {\n if (!isMounted) {\n menusDispatch({\n type: 'SET_VIEWER',\n payload: { currentViewer: validViewer },\n })\n setIsMounted(true)\n }\n }, [isMounted, validViewer, menusDispatch])\n\n React.useEffect(() => {\n if (!organization) return\n const defaultLanguage = organization.languages?.[0] || 'En'\n if (defaultLanguage) void switchLanguage(defaultLanguage)\n }, [organization])\n\n // Handle context changes (from sidebar, HeaderButtons, etc.)\n React.useEffect(() => {\n if (!isMounted || !currentViewer || currentViewer === validViewer || isUpdatingRef.current) {\n return\n }\n\n isUpdatingRef.current = true\n\n // Create URLSearchParams to preserve existing search params\n\n const current = new URLSearchParams(searchParams.toString())\n current.set('viewer', currentViewer)\n const newSearchParams = building?.id ? withBuildingId(current, building.id) : current\n\n\n router.replace(`${pathname}?${newSearchParams.toString()}`, { scroll: false })\n\n // Reset the flag after a brief delay to allow the navigation to complete\n setTimeout(() => {\n isUpdatingRef.current = false\n }, 100)\n }, [currentViewer, isMounted, pathname, router, viewer, searchParams])\n\n // Handle URL changes (direct navigation)\n React.useEffect(() => {\n if (isMounted && currentViewer !== validViewer && !isUpdatingRef.current) {\n isUpdatingRef.current = true\n\n menusDispatch({\n type: 'SET_VIEWER',\n payload: { currentViewer: validViewer },\n })\n\n // Reset the flag after a brief delay\n setTimeout(() => {\n isUpdatingRef.current = false\n }, 100)\n }\n }, [validViewer, menusDispatch, isMounted, currentViewer])\n\n // Null while a plugin page shows, so the branches below stay exhaustive over ViewerNames.\n const builtInViewer = pluginPage ? null : (validViewer as ViewerNames)\n\n const selectedViewer = (\n <>\n {builtInViewer !== null\n && [ViewerNames.map, ViewerNames.bim].includes(builtInViewer)\n && <SidebarTrigger />}\n <div style={{ height: '100%', width: '100%', position: 'relative' }}>\n <div style={{ display: builtInViewer === ViewerNames.map ? 'block' : 'none', width: '100%', height: '100%' }}>\n <MapViewer organization={organization} maptilerKey={maptilerKey} />\n </div>\n {builtInViewer === ViewerNames.bim && <BimViewer pointcloudApiUrl={pointcloudApiUrl} />}\n {builtInViewer !== null\n && [ViewerNames.buildings, ViewerNames.sites, ViewerNames.files, ViewerNames.land, ViewerNames.infrastructure, ViewerNames.users].includes(builtInViewer) && (\n <DataMenu currentViewer={builtInViewer} organization={organization} geocodeEarthApiKey={geocodeEarthApiKey} geocoderUrl={geocoderUrl} />\n )}\n {/* `plugins` used to route through DataMenu, which rendered nothing:\n VIEWER_CONFIG gives it no dataType. It has its own page now. */}\n {builtInViewer === ViewerNames.extensions && (\n <div className=\"h-full w-full overflow-y-auto\">\n <PluginsManager />\n </div>\n )}\n {builtInViewer === ViewerNames.settings && (\n <UserSettings minioBaseUrl={minioBaseUrl} />\n )}\n {pluginPage && (\n <div className=\"h-full w-full overflow-y-auto\">\n <PluginDataPageHost viewer={validViewer} />\n </div>\n )}\n </div>\n </>\n )\n\n return (\n <>\n {selectedViewer}\n <Toolbar viewer={validViewer} minioBaseUrl={minioBaseUrl} martinBaseUrl={martinBaseUrl} organization={organization} geocodeEarthApiKey={geocodeEarthApiKey} geocoderUrl={geocoderUrl} />\n <UploadProgressToasts />\n </>\n )\n}"],"mappings":";AA+B+B,SA0I3B,UA1I2B,KAwBzB,YAxByB;AAzB/B,SAAS,eAAe;AACxB,OAAO,aAAa;AACpB,SAAS,iBAAiB,WAAW,mBAAmB;AACxD,YAAY,WAAW;AAEvB,SAAS,4BAA4B;AACrC,SAAS,kBAAkB,oBAAoB;AAC/C,SAAS,mBAAmB;AAG5B,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AAC7B,SAAS,eAAe;AACxB,SAAS,4BAA4B;AACrC,SAAS,sBAAsB;AAE/B,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAKhC,MAAM,YAAY;AAAA,EAChB,MAAM,OAAO,iBAAiB,EAAE,KAAK,QAAM,EAAE,SAAS,EAAE,UAAU,EAAE;AAAA,EACpE,EAAE,KAAK,OAAO,SAAS,MAAM,oBAAC,yBAAsB,OAAM,4BAAsB,EAAG;AACrF;AAGA,MAAM,iBAAiB;AAAA,EACrB,MAAM,OAAO,0BAA0B,EAAE,KAAK,QAAM,EAAE,SAAS,EAAE,eAAe,EAAE;AAAA,EAClF,EAAE,KAAK,OAAO,SAAS,MAAM,oBAAC,yBAAsB,OAAM,yBAAmB,EAAG;AAClF;AAEA,MAAM,WAAW;AAAA,EACf,MAAM,OAAO,iBAAiB,EAAE,KAAK,QAAM,EAAE,SAAS,EAAE,SAAS,EAAE;AAAA,EACnE,EAA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","names":[]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { Building } from '../../../../../types/dbTypes';
|
|
2
|
+
export declare function withBuildingId(params: URLSearchParams, buildingId: number | string): URLSearchParams;
|
|
2
3
|
export declare function withBuildingLocation(params: URLSearchParams, building: Building): URLSearchParams;
|
|
3
4
|
//# sourceMappingURL=buildingLocationParams.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildingLocationParams.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/bim/src/lib/buildingLocationParams.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;
|
|
1
|
+
{"version":3,"file":"buildingLocationParams.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/bim/src/lib/buildingLocationParams.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AAiB5D,wBAAgB,cAAc,CAAC,MAAM,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,mBAMlF;AAgBD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,QAAQ,mBAU/E"}
|
|
@@ -7,6 +7,14 @@ const BUILDING_LOCATION_PARAMS = [
|
|
|
7
7
|
"zoom"
|
|
8
8
|
];
|
|
9
9
|
const BUILDING_ZOOM = "18";
|
|
10
|
+
const BIM_CAMERA_PARAMS = ["camX", "camY", "camZ", "tarX", "tarY", "tarZ"];
|
|
11
|
+
function withBuildingId(params, buildingId) {
|
|
12
|
+
const next = new URLSearchParams(params.toString());
|
|
13
|
+
const id = String(buildingId);
|
|
14
|
+
if (next.get("buildingId") !== id) BIM_CAMERA_PARAMS.forEach((key) => next.delete(key));
|
|
15
|
+
next.set("buildingId", id);
|
|
16
|
+
return next;
|
|
17
|
+
}
|
|
10
18
|
function locationOf(building) {
|
|
11
19
|
const { buildingLatitude: lat, buildingLongitude: lng } = building;
|
|
12
20
|
const located = typeof lat === "number" && typeof lng === "number";
|
|
@@ -21,8 +29,7 @@ function locationOf(building) {
|
|
|
21
29
|
};
|
|
22
30
|
}
|
|
23
31
|
function withBuildingLocation(params, building) {
|
|
24
|
-
const next =
|
|
25
|
-
next.set("buildingId", String(building.id));
|
|
32
|
+
const next = withBuildingId(params, building.id);
|
|
26
33
|
const location = locationOf(building);
|
|
27
34
|
for (const key of BUILDING_LOCATION_PARAMS) {
|
|
28
35
|
const value = location[key];
|
|
@@ -32,6 +39,7 @@ function withBuildingLocation(params, building) {
|
|
|
32
39
|
return next;
|
|
33
40
|
}
|
|
34
41
|
export {
|
|
42
|
+
withBuildingId,
|
|
35
43
|
withBuildingLocation
|
|
36
44
|
};
|
|
37
45
|
//# sourceMappingURL=buildingLocationParams.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/core/components/viewers/bim/src/lib/buildingLocationParams.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport type { Building } from '../../../../../types/dbTypes'\n\n/** The URL params a selected building owns. Anything absent on the record is cleared, not blanked. */\nconst BUILDING_LOCATION_PARAMS = [\n 'municipality',\n 'countrySubdivision',\n 'address',\n 'lat',\n 'lng',\n 'zoom',\n] as const\n\nconst BUILDING_ZOOM = '18'\n\nfunction locationOf(building: Building) {\n const { buildingLatitude: lat, buildingLongitude: lng } = building\n const located = typeof lat === 'number' && typeof lng === 'number'\n return {\n municipality: building.buildingMunicipality,\n countrySubdivision: building.buildingCountrySubdivision,\n // Deliberately never written: it made the URL unreadable and buildingId already names it.\n address: undefined,\n lat: located ? String(lat) : undefined,\n lng: located ? String(lng) : undefined,\n zoom: located ? BUILDING_ZOOM : undefined,\n }\n}\n\nexport function withBuildingLocation(params: URLSearchParams, building: Building) {\n const next =
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/core/components/viewers/bim/src/lib/buildingLocationParams.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport type { Building } from '../../../../../types/dbTypes'\n\n/** The URL params a selected building owns. Anything absent on the record is cleared, not blanked. */\nconst BUILDING_LOCATION_PARAMS = [\n 'municipality',\n 'countrySubdivision',\n 'address',\n 'lat',\n 'lng',\n 'zoom',\n] as const\n\nconst BUILDING_ZOOM = '18'\n\n/** A shared BIM camera is in one building's coordinates, so it must not survive a switch to another. */\nconst BIM_CAMERA_PARAMS = ['camX', 'camY', 'camZ', 'tarX', 'tarY', 'tarZ'] as const\n\nexport function withBuildingId(params: URLSearchParams, buildingId: number | string) {\n const next = new URLSearchParams(params.toString())\n const id = String(buildingId)\n if (next.get('buildingId') !== id) BIM_CAMERA_PARAMS.forEach(key => next.delete(key))\n next.set('buildingId', id)\n return next\n}\n\nfunction locationOf(building: Building) {\n const { buildingLatitude: lat, buildingLongitude: lng } = building\n const located = typeof lat === 'number' && typeof lng === 'number'\n return {\n municipality: building.buildingMunicipality,\n countrySubdivision: building.buildingCountrySubdivision,\n // Deliberately never written: it made the URL unreadable and buildingId already names it.\n address: undefined,\n lat: located ? String(lat) : undefined,\n lng: located ? String(lng) : undefined,\n zoom: located ? BUILDING_ZOOM : undefined,\n }\n}\n\nexport function withBuildingLocation(params: URLSearchParams, building: Building) {\n const next = withBuildingId(params, building.id)\n\n const location = locationOf(building)\n for (const key of BUILDING_LOCATION_PARAMS) {\n const value = location[key]\n if (value) next.set(key, value)\n else next.delete(key)\n }\n return next\n}\n"],"mappings":"AAMA,MAAM,2BAA2B;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;AAEA,MAAM,gBAAgB;AAGtB,MAAM,oBAAoB,CAAC,QAAQ,QAAQ,QAAQ,QAAQ,QAAQ,MAAM;AAElE,SAAS,eAAe,QAAyB,YAA6B;AACjF,QAAM,OAAO,IAAI,gBAAgB,OAAO,SAAS,CAAC;AAClD,QAAM,KAAK,OAAO,UAAU;AAC5B,MAAI,KAAK,IAAI,YAAY,MAAM,GAAI,mBAAkB,QAAQ,SAAO,KAAK,OAAO,GAAG,CAAC;AACpF,OAAK,IAAI,cAAc,EAAE;AACzB,SAAO;AACX;AAEA,SAAS,WAAW,UAAoB;AACpC,QAAM,EAAE,kBAAkB,KAAK,mBAAmB,IAAI,IAAI;AAC1D,QAAM,UAAU,OAAO,QAAQ,YAAY,OAAO,QAAQ;AAC1D,SAAO;AAAA,IACH,cAAc,SAAS;AAAA,IACvB,oBAAoB,SAAS;AAAA;AAAA,IAE7B,SAAS;AAAA,IACT,KAAK,UAAU,OAAO,GAAG,IAAI;AAAA,IAC7B,KAAK,UAAU,OAAO,GAAG,IAAI;AAAA,IAC7B,MAAM,UAAU,gBAAgB;AAAA,EACpC;AACJ;AAEO,SAAS,qBAAqB,QAAyB,UAAoB;AAC9E,QAAM,OAAO,eAAe,QAAQ,SAAS,EAAE;AAE/C,QAAM,WAAW,WAAW,QAAQ;AACpC,aAAW,OAAO,0BAA0B;AACxC,UAAM,QAAQ,SAAS,GAAG;AAC1B,QAAI,MAAO,MAAK,IAAI,KAAK,KAAK;AAAA,QACzB,MAAK,OAAO,GAAG;AAAA,EACxB;AACA,SAAO;AACX;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setCameraLookAt.d.ts","sourceRoot":"","sources":["../../../../../../src/core/components/viewers/bim/utils/setCameraLookAt.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"setCameraLookAt.d.ts","sourceRoot":"","sources":["../../../../../../src/core/components/viewers/bim/utils/setCameraLookAt.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,GAAG,MAAM,sBAAsB,CAAC;AAWjD,wBAAgB,eAAe,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,YAAY,EAAE,eAAe;;;;;;;;;;;;EAK9E"}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
+
const CAMERA_PARAMS = ["camX", "camY", "camZ", "tarX", "tarY", "tarZ"];
|
|
2
|
+
const DEFAULT_LOOK_AT = [20, 40, 40, -30, 10, -5];
|
|
3
|
+
function sharedLookAt(searchParams) {
|
|
4
|
+
const values = CAMERA_PARAMS.map((key) => {
|
|
5
|
+
var _a;
|
|
6
|
+
return Number.parseFloat((_a = searchParams.get(key)) != null ? _a : "");
|
|
7
|
+
});
|
|
8
|
+
return values.every(Number.isFinite) ? values : null;
|
|
9
|
+
}
|
|
1
10
|
function setCameraLookAt(world, searchParams) {
|
|
2
|
-
const
|
|
3
|
-
const camY =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const tarY = Number(searchParams.get("tarY"));
|
|
7
|
-
const tarZ = Number(searchParams.get("tarZ"));
|
|
8
|
-
if (world && camX && camY && camZ && tarX && tarY && tarZ) {
|
|
9
|
-
world.camera.controls.setLookAt(camX, camY, camZ, tarX, tarY, tarZ, true);
|
|
10
|
-
return { sharing: true, cameraPosition: { x: camX, y: camY, z: camZ }, targetPosition: { x: tarX, y: tarY, z: tarZ } };
|
|
11
|
-
} else {
|
|
12
|
-
world.camera.controls.setLookAt(20, 40, 40, -30, 10, -5, true);
|
|
13
|
-
return { sharing: false, cameraPosition: { x: 20, y: 40, z: 10 }, targetPosition: { x: -30, y: 10, z: -5 } };
|
|
14
|
-
}
|
|
15
|
-
;
|
|
11
|
+
const shared = sharedLookAt(searchParams);
|
|
12
|
+
const [camX, camY, camZ, tarX, tarY, tarZ] = shared != null ? shared : DEFAULT_LOOK_AT;
|
|
13
|
+
void world.camera.controls.setLookAt(camX, camY, camZ, tarX, tarY, tarZ, true);
|
|
14
|
+
return { sharing: shared !== null, cameraPosition: { x: camX, y: camY, z: camZ }, targetPosition: { x: tarX, y: tarY, z: tarZ } };
|
|
16
15
|
}
|
|
17
16
|
export {
|
|
18
17
|
setCameraLookAt
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/core/components/viewers/bim/utils/setCameraLookAt.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/core/components/viewers/bim/utils/setCameraLookAt.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport type * as OBC from \"@thatopen/components\";\n\nconst CAMERA_PARAMS = [\"camX\", \"camY\", \"camZ\", \"tarX\", \"tarY\", \"tarZ\"] as const;\n\nconst DEFAULT_LOOK_AT = [20, 40, 40, -30, 10, -5] as const;\n\nfunction sharedLookAt(searchParams: URLSearchParams): number[] | null {\n const values = CAMERA_PARAMS.map(key => Number.parseFloat(searchParams.get(key) ?? \"\"));\n return values.every(Number.isFinite) ? values : null;\n}\n\nexport function setCameraLookAt(world: OBC.World, searchParams: URLSearchParams) {\n const shared = sharedLookAt(searchParams);\n const [camX, camY, camZ, tarX, tarY, tarZ] = shared ?? DEFAULT_LOOK_AT;\n void world.camera.controls.setLookAt(camX, camY, camZ, tarX, tarY, tarZ, true);\n return { sharing: shared !== null, cameraPosition: { x: camX, y: camY, z: camZ }, targetPosition: { x: tarX, y: tarY, z: tarZ } };\n}\n"],"mappings":"AAKA,MAAM,gBAAgB,CAAC,QAAQ,QAAQ,QAAQ,QAAQ,QAAQ,MAAM;AAErE,MAAM,kBAAkB,CAAC,IAAI,IAAI,IAAI,KAAK,IAAI,EAAE;AAEhD,SAAS,aAAa,cAAgD;AAClE,QAAM,SAAS,cAAc,IAAI,SAAI;AAVzC;AAU4C,kBAAO,YAAW,kBAAa,IAAI,GAAG,MAApB,YAAyB,EAAE;AAAA,GAAC;AACtF,SAAO,OAAO,MAAM,OAAO,QAAQ,IAAI,SAAS;AACpD;AAEO,SAAS,gBAAgB,OAAkB,cAA+B;AAC7E,QAAM,SAAS,aAAa,YAAY;AACxC,QAAM,CAAC,MAAM,MAAM,MAAM,MAAM,MAAM,IAAI,IAAI,0BAAU;AACvD,OAAK,MAAM,OAAO,SAAS,UAAU,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,IAAI;AAC7E,SAAO,EAAE,SAAS,WAAW,MAAM,gBAAgB,EAAE,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,gBAAgB,EAAE,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,EAAE;AACpI;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapViewer.d.ts","sourceRoot":"","sources":["../../../../../src/core/components/viewers/map/MapViewer.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"MapViewer.d.ts","sourceRoot":"","sources":["../../../../../src/core/components/viewers/map/MapViewer.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,MAAM,OAAO,CAAA;AA2BzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAY1D,UAAU,KAAK;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,YAAY,CAAA;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,wBAAgB,SAAS,CAAC,EAAE,KAAc,EAAE,MAAe,EAAE,YAAY,EAAE,WAAW,EAAE,EAAE,KAAK,qBA+M9F"}
|
|
@@ -36,6 +36,8 @@ import { MapClickManager } from "./utils/MapEventManager/MapClickManager";
|
|
|
36
36
|
import { MapHoverManager } from "./utils/MapEventManager/MapHoverManager";
|
|
37
37
|
import { DEFAULT_MAP_STYLE } from "./utils/mapStyleCatalog";
|
|
38
38
|
import { resolveStyleSpec, TERRAIN_SPEC } from "./utils/mapStyleSpec";
|
|
39
|
+
import { presentLevels } from "./utils/urlLocation/locationTarget";
|
|
40
|
+
import { useUrlFlyTo } from "./utils/urlLocation/useUrlFlyTo";
|
|
39
41
|
import { resolveBounds } from "./utils/validateBounds";
|
|
40
42
|
const CANADA_DEFAULTS = {
|
|
41
43
|
zoom: 3,
|
|
@@ -44,16 +46,16 @@ const CANADA_DEFAULTS = {
|
|
|
44
46
|
};
|
|
45
47
|
const MAX_GLOBE_ZOOM = 5;
|
|
46
48
|
function MapViewer({ width = "100%", height = "100%", organization, maptilerKey }) {
|
|
47
|
-
var _a, _b, _c;
|
|
49
|
+
var _a, _b, _c, _d;
|
|
48
50
|
const searchParams = useSearchParams();
|
|
49
51
|
const [isMapLoaded, setIsMapLoaded] = React.useState(false);
|
|
50
52
|
const viewState = React.useMemo(() => {
|
|
51
|
-
var _a2, _b2, _c2,
|
|
52
|
-
return searchParams
|
|
53
|
+
var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i, _j;
|
|
54
|
+
return presentLevels(searchParams)[0] !== "latlng" ? {
|
|
53
55
|
zoom: (_a2 = organization.zoom) != null ? _a2 : CANADA_DEFAULTS.zoom,
|
|
54
56
|
bearing: (_b2 = organization.bearing) != null ? _b2 : 0,
|
|
55
57
|
pitch: (_c2 = organization.pitch) != null ? _c2 : 0,
|
|
56
|
-
longitude: (
|
|
58
|
+
longitude: (_d2 = organization.long) != null ? _d2 : CANADA_DEFAULTS.long,
|
|
57
59
|
latitude: (_e = organization.lat) != null ? _e : CANADA_DEFAULTS.lat
|
|
58
60
|
} : {
|
|
59
61
|
latitude: searchParams.has("lat") ? Number.parseFloat(searchParams.get("lat")) : (_f = organization.lat) != null ? _f : CANADA_DEFAULTS.lat,
|
|
@@ -75,6 +77,7 @@ function MapViewer({ width = "100%", height = "100%", organization, maptilerKey
|
|
|
75
77
|
const mapRef = React.useRef(null);
|
|
76
78
|
const { dispatch: mapDispatch, state: mapState } = React.useContext(MapContext);
|
|
77
79
|
const activeMap = (_a = mapState == null ? void 0 : mapState.map) == null ? void 0 : _a.map;
|
|
80
|
+
useUrlFlyTo(isMapLoaded ? activeMap : void 0, (_b = organization.country) != null ? _b : void 0);
|
|
78
81
|
React.useEffect(() => {
|
|
79
82
|
if (!activeMap) return;
|
|
80
83
|
const enforceProjectionForZoom = () => {
|
|
@@ -102,7 +105,7 @@ function MapViewer({ width = "100%", height = "100%", organization, maptilerKey
|
|
|
102
105
|
};
|
|
103
106
|
}, [activeMap]);
|
|
104
107
|
const handleMapLoad = () => {
|
|
105
|
-
var _a2, _b2, _c2,
|
|
108
|
+
var _a2, _b2, _c2, _d2, _e, _f, _g, _h;
|
|
106
109
|
const map = mapRef.current.getMap();
|
|
107
110
|
if (map.getZoom() > MAX_GLOBE_ZOOM) {
|
|
108
111
|
map.setProjection({ type: "mercator" });
|
|
@@ -131,7 +134,7 @@ function MapViewer({ width = "100%", height = "100%", organization, maptilerKey
|
|
|
131
134
|
lat: searchParams.has("lat") ? Number.parseFloat(searchParams.get("lat")) : (_a2 = organization.lat) != null ? _a2 : CANADA_DEFAULTS.lat,
|
|
132
135
|
lng: searchParams.has("lng") ? Number.parseFloat(searchParams.get("lng")) : (_b2 = organization.long) != null ? _b2 : CANADA_DEFAULTS.long,
|
|
133
136
|
bearing: searchParams.has("bearing") ? Number.parseFloat(searchParams.get("bearing")) : (_c2 = organization.bearing) != null ? _c2 : 0,
|
|
134
|
-
pitch: searchParams.has("pitch") ? Number.parseFloat(searchParams.get("pitch")) : (
|
|
137
|
+
pitch: searchParams.has("pitch") ? Number.parseFloat(searchParams.get("pitch")) : (_d2 = organization.pitch) != null ? _d2 : 0,
|
|
135
138
|
zoom: searchParams.has("zoom") ? Number.parseFloat(searchParams.get("zoom")) : (_e = organization.zoom) != null ? _e : CANADA_DEFAULTS.zoom,
|
|
136
139
|
// Add location details from URL params if available
|
|
137
140
|
countrySubdivision: searchParams.has("countrySubdivision") ? searchParams.get("countrySubdivision") : (_f = organization.countrySubdivision) != null ? _f : "",
|
|
@@ -156,7 +159,7 @@ function MapViewer({ width = "100%", height = "100%", organization, maptilerKey
|
|
|
156
159
|
const coordinates = { lng, lat, elevation, zoom: (_b2 = mapRef.current) == null ? void 0 : _b2.getZoom() };
|
|
157
160
|
console.log("\u{1F4CD} Map coordinates:", coordinates);
|
|
158
161
|
}, []);
|
|
159
|
-
const mapStyle = (
|
|
162
|
+
const mapStyle = (_c = mapState == null ? void 0 : mapState.map.mapStyle) != null ? _c : DEFAULT_MAP_STYLE;
|
|
160
163
|
const mapStyleSpec = React.useMemo(() => resolveStyleSpec(mapStyle, maptilerKey), [mapStyle, maptilerKey]);
|
|
161
164
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
162
165
|
/* @__PURE__ */ jsxs(
|
|
@@ -170,7 +173,7 @@ function MapViewer({ width = "100%", height = "100%", organization, maptilerKey
|
|
|
170
173
|
style: mapContainerStyle,
|
|
171
174
|
initialViewState: viewState,
|
|
172
175
|
maxPitch: 60,
|
|
173
|
-
minZoom: (
|
|
176
|
+
minZoom: (_d = organization == null ? void 0 : organization.minZoom) != null ? _d : CANADA_DEFAULTS.zoom,
|
|
174
177
|
maxBounds: resolveBounds(organization == null ? void 0 : organization.maxBounds),
|
|
175
178
|
projection: initialProjection,
|
|
176
179
|
doubleClickZoom: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/core/components/viewers/map/MapViewer.tsx"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as maplibregl from 'maplibre-gl'\nimport { useSearchParams } from 'next/navigation'\nimport React from 'react'\nimport Map, { NavigationControl } from 'react-map-gl/maplibre'\n\n\nimport { PluginMapLayerHost } from '../../../plugins/host/PluginMapLayerHost'\nimport { MapContext } from '../../../store'\nimport { ViewerNames } from '../../../types/dbTypes'\nimport { SensorLegend } from '../../ui/Sensors/SensorLegend'\nimport SettingsButton from '../../ui/SettingsButton'\nimport { StatsOverlay } from '../../ui/stats'\nimport { ViewerLegendHost } from '../shared/legends/ViewerLegendHost'\n\nimport DatasetManagerMenu from './datasets/DatasetManager'\n\nimport { MapLayers } from './src/MapLayers'\nimport { MapTilerKeyNotice } from './src/MapTilerKeyNotice'\nimport { MapClickManager } from './utils/MapEventManager/MapClickManager'\nimport { MapHoverManager } from './utils/MapEventManager/MapHoverManager'\nimport { DEFAULT_MAP_STYLE } from './utils/mapStyleCatalog'\nimport { resolveStyleSpec, TERRAIN_SPEC } from './utils/mapStyleSpec'\nimport { resolveBounds } from './utils/validateBounds'\n\n\n\n\nimport type { Organization } from '../../../types/dbTypes'\nimport type { CurrentLocation } from '../../../types/map'\nimport type { MapRef} from 'react-map-gl/maplibre';\n\nconst CANADA_DEFAULTS = {\n zoom: 3,\n lat: 56.415,\n long: -98.74,\n} as const\n\nconst MAX_GLOBE_ZOOM = 5\n\ninterface Props {\n width?: string\n height?: string\n organization: Organization\n maptilerKey?: string\n}\n\nexport function MapViewer({ width = '100%', height = '100%', organization, maptilerKey }: Props) {\n\n const searchParams = useSearchParams()\n\n // Add state to track if map is loaded\n const [isMapLoaded, setIsMapLoaded] = React.useState(false)\n\n const viewState = React.useMemo(() => {\n return searchParams.size === 0\n ? {\n zoom: organization.zoom ?? CANADA_DEFAULTS.zoom,\n bearing: organization.bearing ?? 0,\n pitch: organization.pitch ?? 0,\n longitude: organization.long ?? CANADA_DEFAULTS.long,\n latitude: organization.lat ?? CANADA_DEFAULTS.lat,\n }\n : {\n latitude: searchParams.has('lat') ? Number.parseFloat(searchParams.get('lat')) : organization.lat ?? CANADA_DEFAULTS.lat,\n longitude: searchParams.has('lng') ? Number.parseFloat(searchParams.get('lng')) : organization.long ?? CANADA_DEFAULTS.long,\n bearing: searchParams.has('bearing') ? Number.parseFloat(searchParams.get('bearing')) : organization.bearing ?? 0,\n pitch: searchParams.has('pitch') ? Number.parseFloat(searchParams.get('pitch')) : organization.pitch ?? 0,\n zoom: searchParams.has('zoom') ? Number.parseFloat(searchParams.get('zoom')) : organization.zoom ?? CANADA_DEFAULTS.zoom,\n }\n }, [searchParams, organization])\n\n const initialProjection = viewState.zoom > MAX_GLOBE_ZOOM ? 'mercator' : 'globe'\n\n // Memoize the inline style object that gets passed to <Map> for a stable prop identity.\n const mapContainerStyle = React.useMemo(\n () => ({ width, height, backgroundColor: 'black' }),\n [width, height],\n )\n\n // Adaptive pixel ratio. A hardcoded 2 doubled fragment-shader cost on 1× DPR\n // desktops for zero visual gain; capping at 2 keeps phones (DPR 3-4) effective.\n const pixelRatio = React.useMemo(\n () => Math.min(typeof window !== 'undefined' ? window.devicePixelRatio : 1, 2),\n [],\n )\n\n const mapRef = React.useRef<MapRef>(null)\n const { dispatch: mapDispatch, state: mapState } = React.useContext(MapContext)\n\n // Keep the projection in sync with zoom at all times — not only while the\n // map-settings sidebar is mounted. The globe projection degrades past\n // MAX_GLOBE_ZOOM, so we force mercator regardless of which panels are open.\n const activeMap = mapState?.map?.map\n\n React.useEffect(() => {\n if (!activeMap) return\n\n const enforceProjectionForZoom = () => {\n // The globe projection has no fog matrix, so terrain rendering there warns and draws nothing.\n const onGlobe = activeMap.getZoom() <= MAX_GLOBE_ZOOM\n\n if (onGlobe) {\n if (activeMap.getTerrain()) activeMap.setTerrain(null)\n return\n }\n\n if (!activeMap.getTerrain() && activeMap.getSource(TERRAIN_SPEC.source)) {\n activeMap.setTerrain({ ...TERRAIN_SPEC })\n }\n\n const projection = activeMap.getProjection()\n const currentType =\n typeof projection === 'string'\n ? projection\n : (projection as { type?: string; name?: string })?.type ?? (projection as { type?: string; name?: string })?.name\n\n if (currentType !== 'mercator') {\n activeMap.setProjection({ type: 'mercator' })\n }\n }\n\n enforceProjectionForZoom()\n activeMap.on('zoom', enforceProjectionForZoom)\n activeMap.on('styledata', enforceProjectionForZoom)\n\n return () => {\n activeMap.off('zoom', enforceProjectionForZoom)\n activeMap.off('styledata', enforceProjectionForZoom)\n }\n }, [activeMap])\n\n const handleMapLoad = () => {\n const map = mapRef.current.getMap()\n\n if (map.getZoom() > MAX_GLOBE_ZOOM) {\n map.setProjection({ type: 'mercator' })\n }\n\n // Only dispatch SET_MAP after map is fully loaded\n if (mapRef.current) {\n mapDispatch({\n type: 'SET_MAP',\n payload: { map },\n })\n }\n // initilize a new click manager\n const mapClickManager = new MapClickManager(map)\n mapClickManager.onPopupStack(entries =>\n mapDispatch({ type: 'SET_POPUP_STACK', payload: { entries } }),\n )\n mapDispatch({\n type: 'ADD_MAP_CLICK_MANAGER',\n payload: { mapClickManager },\n })\n\n const mapHoverManager = new MapHoverManager(map)\n mapDispatch({\n type: 'ADD_MAP_HOVER_MANAGER',\n payload: { mapHoverManager },\n })\n\n // update current Location with URL params or fallback to theme location\n const updatedLocation: CurrentLocation = {\n // Then override with URL params (this ensures URL params take precedence)\n lat: searchParams.has('lat') ? Number.parseFloat(searchParams.get('lat')) : organization.lat ?? CANADA_DEFAULTS.lat,\n lng: searchParams.has('lng') ? Number.parseFloat(searchParams.get('lng')) : organization.long ?? CANADA_DEFAULTS.long,\n bearing: searchParams.has('bearing') ? Number.parseFloat(searchParams.get('bearing')) : organization.bearing ?? 0,\n pitch: searchParams.has('pitch') ? Number.parseFloat(searchParams.get('pitch')) : organization.pitch ?? 0,\n zoom: searchParams.has('zoom') ? Number.parseFloat(searchParams.get('zoom')) : organization.zoom ?? CANADA_DEFAULTS.zoom,\n // Add location details from URL params if available\n countrySubdivision: searchParams.has('countrySubdivision') ? searchParams.get('countrySubdivision') : (organization.countrySubdivision ?? ''),\n municipality: searchParams.has('municipality') ? searchParams.get('municipality') : (organization.municipality ?? ''),\n address: searchParams.has('address') ? searchParams.get('address') : '', // organization.address,\n site: searchParams.has('site') ? searchParams.get('site') : String(organization.locationSiteId ?? ''),\n id: String(organization.id),\n }\n\n mapDispatch({\n type: 'UPDATE_LOCATION',\n payload: { currentLocation: updatedLocation },\n })\n\n // Set map as loaded after all dispatches are complete\n setIsMapLoaded(true)\n }\n\n // Enable the perf HUD by appending ?debug=1 to the URL. Never reaches\n // production users unless they explicitly opt in.\n const isDebug = searchParams.get('debug') === '1'\n\n // useCallback so the onDblClick prop identity is stable across renders of\n // MapViewer; a new function each render caused react-map-gl to detach/re-attach\n // the listener. The console.log is intentional dev-only coordinate debugging.\n const onDblClick = React.useCallback((e) => {\n if (process.env.NODE_ENV === 'production') return\n const { lng, lat } = e.lngLat\n const elevation = mapRef.current?.queryTerrainElevation([lng, lat]) || 0\n const coordinates = { lng, lat, elevation, zoom: mapRef.current?.getZoom() }\n // eslint-disable-next-line no-console -- intentional dev-mode coordinate logging\n console.log('📍 Map coordinates:', coordinates)\n }, [])\n\n const mapStyle = mapState?.map.mapStyle ?? DEFAULT_MAP_STYLE;\n const mapStyleSpec = React.useMemo(() => resolveStyleSpec(mapStyle, maptilerKey), [mapStyle, maptilerKey]);\n\n return (\n <>\n <Map\n id=\"map-component\"\n mapStyle={mapStyleSpec}\n mapLib={maplibregl}\n onLoad={handleMapLoad}\n ref={mapRef}\n style={mapContainerStyle}\n initialViewState={viewState}\n maxPitch={60}\n minZoom={organization?.minZoom ?? CANADA_DEFAULTS.zoom}\n maxBounds={resolveBounds(organization?.maxBounds)}\n projection={initialProjection}\n doubleClickZoom={false}\n onDblClick={onDblClick}\n pixelRatio={pixelRatio}\n >\n <NavigationControl visualizePitch />\n <SettingsButton />\n {isMapLoaded\n && (\n <>\n <MapLayers organization={organization} maptilerKey={maptilerKey} />\n {/* Bottom-left stack: legend above the layers/styling card, gap auto-managed by flex.\n Lifted clear of the toolbar below the md breakpoint: the toolbar is centred and\n on a phone that centre reaches all the way to this corner. */}\n <div className=\"absolute bottom-20 md:bottom-[10px] left-3 z-10 flex max-w-[calc(100vw-1.5rem)] flex-col gap-2 pointer-events-none\">\n {/* Portal slot for on-map WMS time controls; display:contents so an\n empty slot adds no flex item / gap, but a mounted control stacks\n above the legend + dataset-manager cards. */}\n <div id=\"wms-time-slot\" style={{ display: 'contents' }} />\n <MapTilerKeyNotice maptilerKey={maptilerKey} />\n <SensorLegend />\n <ViewerLegendHost viewer={ViewerNames.map} />\n <DatasetManagerMenu />\n </div>\n </>\n )}\n </Map>\n <StatsOverlay mapRef={mapRef} enabled={isDebug} />\n {/* Renders nothing itself. Outside <Map> and unconditional, so a plugin's layer\n outlives the toolbar panel that created it and survives a viewer switch. */}\n <PluginMapLayerHost />\n </>\n\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoOQ,SAII,UAJJ,KASM,YATN;AA/NR,YAAY,gBAAgB;AAC5B,SAAS,uBAAuB;AAChC,OAAO,WAAW;AAClB,OAAO,OAAO,yBAAyB;AAGvC,SAAS,0BAA0B;AACnC,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,OAAO,oBAAoB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AAEjC,OAAO,wBAAwB;AAE/B,SAAS,iBAAiB;AAC1B,SAAS,yBAAyB;AAClC,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAChC,SAAS,yBAAyB;AAClC,SAAS,kBAAkB,oBAAoB;AAC/C,SAAS,qBAAqB;AAS9B,MAAM,kBAAkB;AAAA,EACtB,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AACR;AAEA,MAAM,iBAAiB;AAShB,SAAS,UAAU,EAAE,QAAQ,QAAQ,SAAS,QAAQ,cAAc,YAAY,GAAU;AAnDjG;AAqDE,QAAM,eAAe,gBAAgB;AAGrC,QAAM,CAAC,aAAa,cAAc,IAAI,MAAM,SAAS,KAAK;AAE1D,QAAM,YAAY,MAAM,QAAQ,MAAM;AA1DxC,QAAAA,KAAAC,KAAAC,KAAA;AA2DI,WAAO,aAAa,SAAS,IACzB;AAAA,MACA,OAAMF,MAAA,aAAa,SAAb,OAAAA,MAAqB,gBAAgB;AAAA,MAC3C,UAASC,MAAA,aAAa,YAAb,OAAAA,MAAwB;AAAA,MACjC,QAAOC,MAAA,aAAa,UAAb,OAAAA,MAAsB;AAAA,MAC7B,YAAW,kBAAa,SAAb,YAAqB,gBAAgB;AAAA,MAChD,WAAU,kBAAa,QAA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AA;AAAA,IAEN;AAAA,IACA,oBAAC,gBAAa,QAAgB,SAAS,SAAS;AAAA,IAGhD,oBAAC,sBAAmB;AAAA,KACtB;AAGJ;","names":["_a","_b","_c"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/core/components/viewers/map/MapViewer.tsx"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as maplibregl from 'maplibre-gl'\nimport { useSearchParams } from 'next/navigation'\nimport React from 'react'\nimport Map, { NavigationControl } from 'react-map-gl/maplibre'\n\n\nimport { PluginMapLayerHost } from '../../../plugins/host/PluginMapLayerHost'\nimport { MapContext } from '../../../store'\nimport { ViewerNames } from '../../../types/dbTypes'\nimport { SensorLegend } from '../../ui/Sensors/SensorLegend'\nimport SettingsButton from '../../ui/SettingsButton'\nimport { StatsOverlay } from '../../ui/stats'\nimport { ViewerLegendHost } from '../shared/legends/ViewerLegendHost'\n\nimport DatasetManagerMenu from './datasets/DatasetManager'\n\nimport { MapLayers } from './src/MapLayers'\nimport { MapTilerKeyNotice } from './src/MapTilerKeyNotice'\nimport { MapClickManager } from './utils/MapEventManager/MapClickManager'\nimport { MapHoverManager } from './utils/MapEventManager/MapHoverManager'\nimport { DEFAULT_MAP_STYLE } from './utils/mapStyleCatalog'\nimport { resolveStyleSpec, TERRAIN_SPEC } from './utils/mapStyleSpec'\nimport { presentLevels } from './utils/urlLocation/locationTarget'\nimport { useUrlFlyTo } from './utils/urlLocation/useUrlFlyTo'\nimport { resolveBounds } from './utils/validateBounds'\n\n\n\n\nimport type { Organization } from '../../../types/dbTypes'\nimport type { CurrentLocation } from '../../../types/map'\nimport type { MapRef} from 'react-map-gl/maplibre';\n\nconst CANADA_DEFAULTS = {\n zoom: 3,\n lat: 56.415,\n long: -98.74,\n} as const\n\nconst MAX_GLOBE_ZOOM = 5\n\ninterface Props {\n width?: string\n height?: string\n organization: Organization\n maptilerKey?: string\n}\n\nexport function MapViewer({ width = '100%', height = '100%', organization, maptilerKey }: Props) {\n\n const searchParams = useSearchParams()\n\n // Add state to track if map is loaded\n const [isMapLoaded, setIsMapLoaded] = React.useState(false)\n\n const viewState = React.useMemo(() => {\n return presentLevels(searchParams)[0] !== 'latlng'\n ? {\n zoom: organization.zoom ?? CANADA_DEFAULTS.zoom,\n bearing: organization.bearing ?? 0,\n pitch: organization.pitch ?? 0,\n longitude: organization.long ?? CANADA_DEFAULTS.long,\n latitude: organization.lat ?? CANADA_DEFAULTS.lat,\n }\n : {\n latitude: searchParams.has('lat') ? Number.parseFloat(searchParams.get('lat')) : organization.lat ?? CANADA_DEFAULTS.lat,\n longitude: searchParams.has('lng') ? Number.parseFloat(searchParams.get('lng')) : organization.long ?? CANADA_DEFAULTS.long,\n bearing: searchParams.has('bearing') ? Number.parseFloat(searchParams.get('bearing')) : organization.bearing ?? 0,\n pitch: searchParams.has('pitch') ? Number.parseFloat(searchParams.get('pitch')) : organization.pitch ?? 0,\n zoom: searchParams.has('zoom') ? Number.parseFloat(searchParams.get('zoom')) : organization.zoom ?? CANADA_DEFAULTS.zoom,\n }\n }, [searchParams, organization])\n\n const initialProjection = viewState.zoom > MAX_GLOBE_ZOOM ? 'mercator' : 'globe'\n\n // Memoize the inline style object that gets passed to <Map> for a stable prop identity.\n const mapContainerStyle = React.useMemo(\n () => ({ width, height, backgroundColor: 'black' }),\n [width, height],\n )\n\n // Adaptive pixel ratio. A hardcoded 2 doubled fragment-shader cost on 1× DPR\n // desktops for zero visual gain; capping at 2 keeps phones (DPR 3-4) effective.\n const pixelRatio = React.useMemo(\n () => Math.min(typeof window !== 'undefined' ? window.devicePixelRatio : 1, 2),\n [],\n )\n\n const mapRef = React.useRef<MapRef>(null)\n const { dispatch: mapDispatch, state: mapState } = React.useContext(MapContext)\n\n // Keep the projection in sync with zoom at all times — not only while the\n // map-settings sidebar is mounted. The globe projection degrades past\n // MAX_GLOBE_ZOOM, so we force mercator regardless of which panels are open.\n const activeMap = mapState?.map?.map\n useUrlFlyTo(isMapLoaded ? activeMap : undefined, organization.country ?? undefined)\n\n React.useEffect(() => {\n if (!activeMap) return\n\n const enforceProjectionForZoom = () => {\n // The globe projection has no fog matrix, so terrain rendering there warns and draws nothing.\n const onGlobe = activeMap.getZoom() <= MAX_GLOBE_ZOOM\n\n if (onGlobe) {\n if (activeMap.getTerrain()) activeMap.setTerrain(null)\n return\n }\n\n if (!activeMap.getTerrain() && activeMap.getSource(TERRAIN_SPEC.source)) {\n activeMap.setTerrain({ ...TERRAIN_SPEC })\n }\n\n const projection = activeMap.getProjection()\n const currentType =\n typeof projection === 'string'\n ? projection\n : (projection as { type?: string; name?: string })?.type ?? (projection as { type?: string; name?: string })?.name\n\n if (currentType !== 'mercator') {\n activeMap.setProjection({ type: 'mercator' })\n }\n }\n\n enforceProjectionForZoom()\n activeMap.on('zoom', enforceProjectionForZoom)\n activeMap.on('styledata', enforceProjectionForZoom)\n\n return () => {\n activeMap.off('zoom', enforceProjectionForZoom)\n activeMap.off('styledata', enforceProjectionForZoom)\n }\n }, [activeMap])\n\n const handleMapLoad = () => {\n const map = mapRef.current.getMap()\n\n if (map.getZoom() > MAX_GLOBE_ZOOM) {\n map.setProjection({ type: 'mercator' })\n }\n\n // Only dispatch SET_MAP after map is fully loaded\n if (mapRef.current) {\n mapDispatch({\n type: 'SET_MAP',\n payload: { map },\n })\n }\n // initilize a new click manager\n const mapClickManager = new MapClickManager(map)\n mapClickManager.onPopupStack(entries =>\n mapDispatch({ type: 'SET_POPUP_STACK', payload: { entries } }),\n )\n mapDispatch({\n type: 'ADD_MAP_CLICK_MANAGER',\n payload: { mapClickManager },\n })\n\n const mapHoverManager = new MapHoverManager(map)\n mapDispatch({\n type: 'ADD_MAP_HOVER_MANAGER',\n payload: { mapHoverManager },\n })\n\n // update current Location with URL params or fallback to theme location\n const updatedLocation: CurrentLocation = {\n // Then override with URL params (this ensures URL params take precedence)\n lat: searchParams.has('lat') ? Number.parseFloat(searchParams.get('lat')) : organization.lat ?? CANADA_DEFAULTS.lat,\n lng: searchParams.has('lng') ? Number.parseFloat(searchParams.get('lng')) : organization.long ?? CANADA_DEFAULTS.long,\n bearing: searchParams.has('bearing') ? Number.parseFloat(searchParams.get('bearing')) : organization.bearing ?? 0,\n pitch: searchParams.has('pitch') ? Number.parseFloat(searchParams.get('pitch')) : organization.pitch ?? 0,\n zoom: searchParams.has('zoom') ? Number.parseFloat(searchParams.get('zoom')) : organization.zoom ?? CANADA_DEFAULTS.zoom,\n // Add location details from URL params if available\n countrySubdivision: searchParams.has('countrySubdivision') ? searchParams.get('countrySubdivision') : (organization.countrySubdivision ?? ''),\n municipality: searchParams.has('municipality') ? searchParams.get('municipality') : (organization.municipality ?? ''),\n address: searchParams.has('address') ? searchParams.get('address') : '', // organization.address,\n site: searchParams.has('site') ? searchParams.get('site') : String(organization.locationSiteId ?? ''),\n id: String(organization.id),\n }\n\n mapDispatch({\n type: 'UPDATE_LOCATION',\n payload: { currentLocation: updatedLocation },\n })\n\n // Set map as loaded after all dispatches are complete\n setIsMapLoaded(true)\n }\n\n // Enable the perf HUD by appending ?debug=1 to the URL. Never reaches\n // production users unless they explicitly opt in.\n const isDebug = searchParams.get('debug') === '1'\n\n // useCallback so the onDblClick prop identity is stable across renders of\n // MapViewer; a new function each render caused react-map-gl to detach/re-attach\n // the listener. The console.log is intentional dev-only coordinate debugging.\n const onDblClick = React.useCallback((e) => {\n if (process.env.NODE_ENV === 'production') return\n const { lng, lat } = e.lngLat\n const elevation = mapRef.current?.queryTerrainElevation([lng, lat]) || 0\n const coordinates = { lng, lat, elevation, zoom: mapRef.current?.getZoom() }\n // eslint-disable-next-line no-console -- intentional dev-mode coordinate logging\n console.log('📍 Map coordinates:', coordinates)\n }, [])\n\n const mapStyle = mapState?.map.mapStyle ?? DEFAULT_MAP_STYLE;\n const mapStyleSpec = React.useMemo(() => resolveStyleSpec(mapStyle, maptilerKey), [mapStyle, maptilerKey]);\n\n return (\n <>\n <Map\n id=\"map-component\"\n mapStyle={mapStyleSpec}\n mapLib={maplibregl}\n onLoad={handleMapLoad}\n ref={mapRef}\n style={mapContainerStyle}\n initialViewState={viewState}\n maxPitch={60}\n minZoom={organization?.minZoom ?? CANADA_DEFAULTS.zoom}\n maxBounds={resolveBounds(organization?.maxBounds)}\n projection={initialProjection}\n doubleClickZoom={false}\n onDblClick={onDblClick}\n pixelRatio={pixelRatio}\n >\n <NavigationControl visualizePitch />\n <SettingsButton />\n {isMapLoaded\n && (\n <>\n <MapLayers organization={organization} maptilerKey={maptilerKey} />\n {/* Bottom-left stack: legend above the layers/styling card, gap auto-managed by flex.\n Lifted clear of the toolbar below the md breakpoint: the toolbar is centred and\n on a phone that centre reaches all the way to this corner. */}\n <div className=\"absolute bottom-20 md:bottom-[10px] left-3 z-10 flex max-w-[calc(100vw-1.5rem)] flex-col gap-2 pointer-events-none\">\n {/* Portal slot for on-map WMS time controls; display:contents so an\n empty slot adds no flex item / gap, but a mounted control stacks\n above the legend + dataset-manager cards. */}\n <div id=\"wms-time-slot\" style={{ display: 'contents' }} />\n <MapTilerKeyNotice maptilerKey={maptilerKey} />\n <SensorLegend />\n <ViewerLegendHost viewer={ViewerNames.map} />\n <DatasetManagerMenu />\n </div>\n </>\n )}\n </Map>\n <StatsOverlay mapRef={mapRef} enabled={isDebug} />\n {/* Renders nothing itself. Outside <Map> and unconditional, so a plugin's layer\n outlives the toolbar panel that created it and survives a viewer switch. */}\n <PluginMapLayerHost />\n </>\n\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAuOQ,SAII,UAJJ,KASM,YATN;AAlOR,YAAY,gBAAgB;AAC5B,SAAS,uBAAuB;AAChC,OAAO,WAAW;AAClB,OAAO,OAAO,yBAAyB;AAGvC,SAAS,0BAA0B;AACnC,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,OAAO,oBAAoB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AAEjC,OAAO,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E3E,YAAQ,IAAI,8BAAuB,WAAW;AAAA,EAChD,GAAG,CAAC,CAAC;AAEL,QAAM,YAAW,0CAAU,IAAI,aAAd,YAA0B;AAC3C,QAAM,eAAe,MAAM,QAAQ,MAAM,iBAAiB,UAAU,WAAW,GAAG,CAAC,UAAU,WAAW,CAAC;AAEzG,SACE,iCACE;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,IAAG;AAAA,QACH,UAAU;AAAA,QACV,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,KAAK;AAAA,QACL,OAAO;AAAA,QACP,kBAAkB;AAAA,QAClB,UAAU;AAAA,QACV,UAAS,kDAAc,YAAd,YAAyB,gBAAgB;AAAA,QAClD,WAAW,cAAc,6CAAc,SAAS;AAAA,QAChD,YAAY;AAAA,QACZ,iBAAiB;AAAA,QACjB;AAAA,QACA;AAAA,QAEA;AAAA,8BAAC,qBAAkB,gBAAc,MAAC;AAAA,UAClC,oBAAC,kBAAe;AAAA,UACf,eAEG,iCACE;AAAA,gCAAC,aAAU,cAA4B,aAA0B;AAAA,YAIjE,qBAAC,SAAI,WAAU,sHAIb;AAAA,kCAAC,SAAI,IAAG,iBAAgB,OAAO,EAAE,SAAS,WAAW,GAAG;AAAA,cACxD,oBAAC,qBAAkB,aAA0B;AAAA,cAC7C,oBAAC,gBAAa;AAAA,cACd,oBAAC,oBAAiB,QAAQ,YAAY,KAAK;AAAA,cAC3C,oBAAC,sBAAmB;AAAA,eACtB;AAAA,aACF;AAAA;AAAA;AAAA,IAEN;AAAA,IACA,oBAAC,gBAAa,QAAgB,SAAS,SAAS;AAAA,IAGhD,oBAAC,sBAAmB;AAAA,KACtB;AAGJ;","names":["_a","_b","_c","_d"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Geocoder.d.ts","sourceRoot":"","sources":["../../../../../../src/core/components/viewers/map/src/Geocoder.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"Geocoder.d.ts","sourceRoot":"","sources":["../../../../../../src/core/components/viewers/map/src/Geocoder.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAuC9B,UAAU,aAAa;IACrB,QAAQ,CAAC,EAAE,CAAC,WAAW,EAAE,GAAG,KAAK,IAAI,CAAA;IACrC,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC/B,QAAQ,EACR,qBAA4B,EAC5B,cAAsB,EACtB,kBAAkB,EAClB,WAAW,GACZ,EAAE,aAAa,qBAiRf"}
|
|
@@ -34,6 +34,15 @@ import { Input } from "../../../ui/Input";
|
|
|
34
34
|
import { LoadingSpinner } from "../../../ui/LoadingSpinner";
|
|
35
35
|
import { Separator } from "../../../ui/Separator";
|
|
36
36
|
import { fetchSuggestions, parseLocation, handleLocationSelect, buildingToFeature } from "../utils/geocoder";
|
|
37
|
+
import { labelsFromParams, labelsFromPlace, writeLocationParams } from "../utils/urlLocation/locationParams";
|
|
38
|
+
function labelsFor(feature, type) {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
const props = (_a = feature.properties) != null ? _a : {};
|
|
41
|
+
const address = String((_b = props.label) != null ? _b : "").split(",")[0].trim();
|
|
42
|
+
const place = type === "dbBuilding" ? { municipality: props.municipality, countrySubdivision: props.countrySubdivision, address } : labelsFromPlace(props, address);
|
|
43
|
+
const { country } = labelsFromParams(new URL(window.location.href).searchParams);
|
|
44
|
+
return __spreadValues({ country }, Object.fromEntries(Object.entries(place).filter(([, value]) => value)));
|
|
45
|
+
}
|
|
37
46
|
function Geocoder({
|
|
38
47
|
onSelect,
|
|
39
48
|
showDatabaseBuildings = true,
|
|
@@ -123,38 +132,32 @@ function Geocoder({
|
|
|
123
132
|
};
|
|
124
133
|
}, [alwaysExpanded]);
|
|
125
134
|
const handleSelectSuggestion = (feature, type = "") => {
|
|
126
|
-
var _a;
|
|
135
|
+
var _a, _b, _c, _d;
|
|
127
136
|
setQuery("");
|
|
128
137
|
setSuggestions([]);
|
|
129
138
|
setBuildingResults([]);
|
|
130
139
|
if (!alwaysExpanded) {
|
|
131
140
|
setFocused(false);
|
|
132
141
|
}
|
|
133
|
-
const
|
|
142
|
+
const syncUrl = () => {
|
|
143
|
+
if (map) writeLocationParams(map, labelsFor(feature, type));
|
|
144
|
+
};
|
|
145
|
+
const addressData = handleLocationSelect(feature, map, type, { onMoveEnd: syncUrl });
|
|
134
146
|
const address2 = addressData.formatted_address || ((_a = feature.properties) == null ? void 0 : _a.label) || "";
|
|
135
147
|
setAddress(address2);
|
|
136
148
|
setSelectedAddress(addressData);
|
|
137
149
|
if (onSelect) onSelect(addressData);
|
|
138
|
-
if (mapDispatch && currentLocation) {
|
|
150
|
+
if (mapDispatch && currentLocation && addressData.coordinates) {
|
|
139
151
|
const [lng, lat] = addressData.coordinates;
|
|
140
|
-
const
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
152
|
+
const labels = labelsFor(feature, type);
|
|
153
|
+
const newCurrentLocation = __spreadProps(__spreadValues({}, currentLocation), {
|
|
154
|
+
municipality: (_b = labels.municipality) != null ? _b : "",
|
|
155
|
+
countrySubdivision: (_c = labels.countrySubdivision) != null ? _c : "",
|
|
156
|
+
address: (_d = labels.address) != null ? _d : "",
|
|
157
|
+
lng,
|
|
158
|
+
lat
|
|
159
|
+
});
|
|
145
160
|
mapDispatch({ type: "UPDATE_LOCATION", payload: { currentLocation: newCurrentLocation } });
|
|
146
|
-
if (municipality || countrySubdivision) {
|
|
147
|
-
const url = new URL(window.location.href);
|
|
148
|
-
if (municipality) url.searchParams.set("municipality", municipality);
|
|
149
|
-
else url.searchParams.delete("municipality");
|
|
150
|
-
if (countrySubdivision) url.searchParams.set("countrySubdivision", countrySubdivision);
|
|
151
|
-
else url.searchParams.delete("countrySubdivision");
|
|
152
|
-
url.searchParams.set("address", parts[0]);
|
|
153
|
-
url.searchParams.set("lng", lng.toString());
|
|
154
|
-
url.searchParams.set("lat", lat.toString());
|
|
155
|
-
url.searchParams.set("zoom", "18");
|
|
156
|
-
window.history.replaceState({}, "", url.toString());
|
|
157
|
-
}
|
|
158
161
|
}
|
|
159
162
|
};
|
|
160
163
|
const handleExpand = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/core/components/viewers/map/src/Geocoder.tsx"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\n// Dependencies\nimport { Search } from 'lucide-react'\nimport { usePathname } from 'next/navigation'\nimport { useTranslations } from 'next-intl'\nimport * as React from 'react'\n\n// Context\nimport { useBuildings } from '../../../../hooks/buildings/buildings'\nimport { useGeocodingRuntimeConfig } from '../../../../hooks/useGeocodingRuntimeConfig'\nimport { MapContext } from '../../../../store'\n\n// Utility functions\n\n// Import the shadcn components\nimport { Button } from '../../../ui/Button'\nimport { Command, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandSeparator } from '../../../ui/Command'\nimport { Input } from '../../../ui/Input'\nimport { LoadingSpinner } from '../../../ui/LoadingSpinner'\nimport { Separator } from '../../../ui/Separator'\n\n// Icons\n\n// Building data hook\n\n\nimport { fetchSuggestions, parseLocation, handleLocationSelect, buildingToFeature } from '../utils/geocoder'\n\nimport type { CurrentLocation } from '../../../../types/map'\n\n\ninterface GeocoderProps {\n onSelect?: (addressData: any) => void\n showDatabaseBuildings?: boolean\n alwaysExpanded?: boolean\n geocodeEarthApiKey?: string\n geocoderUrl?: string\n}\n\nexport default function Geocoder({\n onSelect,\n showDatabaseBuildings = true,\n alwaysExpanded = false,\n geocodeEarthApiKey,\n geocoderUrl,\n}: GeocoderProps) {\n useGeocodingRuntimeConfig({ geocodeEarthApiKey, geocoderUrl })\n\n // Translation\n const t = useTranslations('Geocoder')\n\n const [address, setAddress] = React.useState<string>('')\n const [query, setQuery] = React.useState('')\n const [suggestions, setSuggestions] = React.useState([])\n const [buildingResults, setBuildingResults] = React.useState([])\n const [focused, setFocused] = React.useState(alwaysExpanded)\n const [selectedAddress, setSelectedAddress] = React.useState(null)\n const [isExpanded, setIsExpanded] = React.useState(alwaysExpanded)\n const [loading, setLoading] = React.useState(false)\n\n const pathname = usePathname()\n\n const suggestionsRef = React.useRef(null)\n const inputRef = React.useRef(null)\n const debounceRef = React.useRef(null)\n\n const { dispatch: mapDispatch, state: mapState } = React.useContext(MapContext)\n const { map, currentLocation, organizationCountry } = mapState.map\n\n // Fetch buildings data from API only if showDatabaseBuildings is true\n const { buildings, isLoading: isBuildingsLoading } = useBuildings()\n\n // Filter buildings based on search query\n const filterBuildings = React.useCallback((searchQuery) => {\n if (!showDatabaseBuildings || !buildings || !searchQuery || searchQuery.length < 3) return []\n\n const lowerQuery = searchQuery.toLowerCase()\n\n if (Array.isArray(buildings) && buildings.length > 0) {\n return buildings.filter((building) => {\n return (\n (building.buildingName && building.buildingName.toLowerCase().includes(lowerQuery))\n || (building.buildingAddress && building.buildingAddress.toLowerCase().includes(lowerQuery))\n || (building.buildingMunicipality && building.buildingMunicipality.toLowerCase().includes(lowerQuery))\n || (building.buildingCountrySubdivision && building.buildingCountrySubdivision.toLowerCase().includes(lowerQuery))\n )\n }).slice(0, 3) // Limit to 3 results\n }\n return []\n }, [buildings, showDatabaseBuildings])\n\n // Debounce the API request to avoid rate limiting and excessive requests\n React.useEffect(() => {\n if (debounceRef.current) {\n clearTimeout(debounceRef.current)\n }\n\n const fetchDebounced = async () => {\n if (!query || query.length < 3) {\n setSuggestions([])\n setBuildingResults([])\n setLoading(false)\n return\n }\n\n setLoading(true)\n try {\n // Filter buildings from our database only if enabled\n if (showDatabaseBuildings) {\n const filteredBuildings = filterBuildings(query)\n setBuildingResults(filteredBuildings)\n }\n\n // Fetch geocoding suggestions\n const geocodeResults = await fetchSuggestions(query, organizationCountry)\n\n // Deduplicate geocode results based on name and region\n const deduplicatedResults = geocodeResults.reduce((acc, feature) => {\n const location = parseLocation(feature)\n // Create a unique key based on name and region (case-insensitive)\n const key = `${location.name?.toLowerCase() || ''}_${location.region?.toLowerCase() || ''}`\n\n // Only add if we haven't seen this combination before\n if (!acc.seen.has(key)) {\n acc.seen.add(key)\n acc.features.push(feature)\n }\n\n return acc\n }, { seen: new Set(), features: [] })\n\n setSuggestions(deduplicatedResults.features)\n }\n catch (error) {\n console.error('Error fetching suggestions:', error)\n setSuggestions([])\n }\n finally {\n setLoading(false)\n }\n }\n\n debounceRef.current = setTimeout(() => { void fetchDebounced() }, 300) // Increased debounce time for better API rate limiting\n\n return () => {\n if (debounceRef.current) clearTimeout(debounceRef.current)\n }\n }, [query, filterBuildings, showDatabaseBuildings])\n\n // Handle click outside to close suggestions\n React.useEffect(() => {\n const handleClickOutside = (event) => {\n if (suggestionsRef.current && !suggestionsRef.current.contains(event.target)\n && inputRef.current && !inputRef.current.contains(event.target) // Don't close if alwaysExpanded is true\n && !alwaysExpanded) {\n setFocused(false)\n }\n }\n\n document.addEventListener('mousedown', handleClickOutside)\n return () => {\n document.removeEventListener('mousedown', handleClickOutside)\n }\n }, [alwaysExpanded])\n\n // Handle suggestion selection\n const handleSelectSuggestion = (feature, type = '') => {\n setQuery('') // Clear the input field\n setSuggestions([])\n setBuildingResults([])\n if (!alwaysExpanded) {\n setFocused(false)\n }\n\n // handleLocationSelect will automatically remove any existing marker and add a new one\n const addressData = handleLocationSelect(feature, map, type)\n\n const address = addressData.formatted_address || feature.properties?.label || ''\n setAddress(address)\n setSelectedAddress(addressData)\n\n if (onSelect) onSelect(addressData)\n\n if (mapDispatch && currentLocation) {\n const [lng, lat] = addressData.coordinates\n const props = addressData.properties || {}\n const parts = address.split(',').map(p => p.trim())\n // Read structured properties (provider-agnostic) instead of parsing label tokens,\n // which only matched Geocode Earth's \"…, ON, Canada\" abbreviation format and broke\n // on the Photon/Nominatim fallback.\n const countrySubdivision: string = props.region_a || props.region || ''\n const municipality: string = props.locality || props.neighbourhood || props.county || ''\n\n const newCurrentLocation: CurrentLocation = { ...currentLocation, municipality, countrySubdivision, longitude: lng, latitude: lat, address: parts[0] }\n mapDispatch({ type: 'UPDATE_LOCATION', payload: { currentLocation: newCurrentLocation } })\n if (municipality || countrySubdivision) {\n const url = new URL(window.location.href)\n // Write each field only when present, so an empty param doesn't shadow the\n // organization fallback MapViewer applies on reload.\n if (municipality) url.searchParams.set('municipality', municipality)\n else url.searchParams.delete('municipality')\n if (countrySubdivision) url.searchParams.set('countrySubdivision', countrySubdivision)\n else url.searchParams.delete('countrySubdivision')\n url.searchParams.set('address', parts[0])\n url.searchParams.set('lng', lng.toString())\n url.searchParams.set('lat', lat.toString())\n url.searchParams.set('zoom', '18')\n window.history.replaceState({}, '', url.toString())\n }\n }\n }\n\n // Handle expand of menubar to display search input\n const handleExpand = () => {\n if (alwaysExpanded) return // Don't allow toggling if always expanded\n\n setIsExpanded(!isExpanded)\n if (isExpanded) {\n setFocused(false)\n setQuery('') // clear input and suggestions when collapsed\n setSuggestions([])\n setBuildingResults([])\n }\n else {\n setFocused(true)\n setTimeout(() => {\n inputRef.current?.focus()\n }, 100) // Small delay to ensure the input is rendered\n }\n }\n\n return (\n <Command>\n {/* Search input + button */}\n <div className={`flex flex-row justify-start items-center w-full h-auto `}>\n {!alwaysExpanded && (\n <Button\n variant=\"ghost\"\n size=\"icon\"\n onClick={handleExpand}\n className=\"opacity-70 w-6 justify-end hover:opacity-100 transition-opacity duration-200 hover:bg-transparent\"\n >\n <Search />\n </Button>\n )}\n {alwaysExpanded && (\n <Search className=\"h-4 w-4 opacity-50\" />\n )}\n <Input\n ref={inputRef}\n type=\"text\"\n value={query}\n onChange={e => setQuery(e.target.value)}\n onFocus={() => setFocused(true)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n inputRef.current?.blur()\n }\n }}\n placeholder={alwaysExpanded ? t('placeholder1') : t('placeholder2')}\n className={`border-none focus-visible:ring-transparent text-sm transition-all ease-in-out duration-200 ${\n alwaysExpanded || isExpanded ? 'w-full' : 'w-0 p-0'\n }`}\n />\n </div>\n\n {focused && (loading || buildingResults.length > 0 || suggestions.length > 0) && (\n <div ref={suggestionsRef}>\n <Separator />\n <CommandList>\n {!loading && buildingResults.length === 0 && suggestions.length === 0 && query.length >= 3 && (\n <CommandEmpty>{showDatabaseBuildings ? t('noResults') : t('noAddresses')}</CommandEmpty>\n )}\n\n {loading && (\n <CommandEmpty><LoadingSpinner /></CommandEmpty>\n )}\n\n {/* Database Buildings section - only show if enabled */}\n {showDatabaseBuildings && !loading && buildingResults.length > 0 && (\n <CommandGroup heading={t('buildingHeader')}>\n {buildingResults.map((building) => {\n const buildingFeature = buildingToFeature(building)\n\n return (\n <CommandItem\n key={`building-${building.id}`}\n onSelect={() => handleSelectSuggestion(buildingFeature, 'dbBuilding')}\n className=\"cursor-pointer\"\n >\n <div className=\"font-medium\">{building.buildingName}</div>\n <div className=\"text-sm text-muted-foreground\">\n {building.buildingAddress}\n </div>\n </CommandItem>\n )\n })}\n </CommandGroup>\n )}\n\n {/* Separator between sections if both have results */}\n {showDatabaseBuildings && buildingResults.length > 0 && suggestions.length > 0 && (\n <CommandSeparator />\n )}\n\n {/* Geocoder suggestions section */}\n {!loading && suggestions.length > 0 && (\n <CommandGroup heading={showDatabaseBuildings ? t('suggestionsHeader') : undefined}>\n {suggestions.map((feature) => {\n const location = parseLocation(feature)\n const uniqueKey = feature.properties?.gid\n || `${feature.properties?.name}-${feature.geometry?.coordinates?.[0]}-${feature.geometry?.coordinates?.[1]}`\n\n return (\n <CommandItem\n key={uniqueKey}\n onSelect={() => handleSelectSuggestion(feature)}\n className=\"cursor-pointer\"\n >\n <div className=\"font-medium\">{location.name}</div>\n <div className=\"text-sm text-muted-foreground\">{location.region}</div>\n </CommandItem>\n )\n })}\n </CommandG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
|
+
{"version":3,"sources":["../../../../../../src/core/components/viewers/map/src/Geocoder.tsx"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\n// Dependencies\nimport { Search } from 'lucide-react'\nimport { usePathname } from 'next/navigation'\nimport { useTranslations } from 'next-intl'\nimport * as React from 'react'\n\n// Context\nimport { useBuildings } from '../../../../hooks/buildings/buildings'\nimport { useGeocodingRuntimeConfig } from '../../../../hooks/useGeocodingRuntimeConfig'\nimport { MapContext } from '../../../../store'\n\n// Utility functions\n\n// Import the shadcn components\nimport { Button } from '../../../ui/Button'\nimport { Command, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandSeparator } from '../../../ui/Command'\nimport { Input } from '../../../ui/Input'\nimport { LoadingSpinner } from '../../../ui/LoadingSpinner'\nimport { Separator } from '../../../ui/Separator'\n\n// Icons\n\n// Building data hook\n\n\nimport { fetchSuggestions, parseLocation, handleLocationSelect, buildingToFeature } from '../utils/geocoder'\nimport { labelsFromParams, labelsFromPlace, writeLocationParams } from '../utils/urlLocation/locationParams'\n\nimport type { CurrentLocation } from '../../../../types/map'\nimport type { LocationLabels } from '../utils/urlLocation/locationParams'\nimport type { Feature } from 'geojson'\n\nfunction labelsFor(feature: Feature, type: string): LocationLabels {\n const props = feature.properties ?? {}\n const address = String(props.label ?? '').split(',')[0].trim()\n const place = type === 'dbBuilding'\n ? { municipality: props.municipality, countrySubdivision: props.countrySubdivision, address }\n : labelsFromPlace(props, address)\n const { country } = labelsFromParams(new URL(window.location.href).searchParams)\n return { country, ...Object.fromEntries(Object.entries(place).filter(([, value]) => value)) }\n}\n\n\ninterface GeocoderProps {\n onSelect?: (addressData: any) => void\n showDatabaseBuildings?: boolean\n alwaysExpanded?: boolean\n geocodeEarthApiKey?: string\n geocoderUrl?: string\n}\n\nexport default function Geocoder({\n onSelect,\n showDatabaseBuildings = true,\n alwaysExpanded = false,\n geocodeEarthApiKey,\n geocoderUrl,\n}: GeocoderProps) {\n useGeocodingRuntimeConfig({ geocodeEarthApiKey, geocoderUrl })\n\n // Translation\n const t = useTranslations('Geocoder')\n\n const [address, setAddress] = React.useState<string>('')\n const [query, setQuery] = React.useState('')\n const [suggestions, setSuggestions] = React.useState([])\n const [buildingResults, setBuildingResults] = React.useState([])\n const [focused, setFocused] = React.useState(alwaysExpanded)\n const [selectedAddress, setSelectedAddress] = React.useState(null)\n const [isExpanded, setIsExpanded] = React.useState(alwaysExpanded)\n const [loading, setLoading] = React.useState(false)\n\n const pathname = usePathname()\n\n const suggestionsRef = React.useRef(null)\n const inputRef = React.useRef(null)\n const debounceRef = React.useRef(null)\n\n const { dispatch: mapDispatch, state: mapState } = React.useContext(MapContext)\n const { map, currentLocation, organizationCountry } = mapState.map\n\n // Fetch buildings data from API only if showDatabaseBuildings is true\n const { buildings, isLoading: isBuildingsLoading } = useBuildings()\n\n // Filter buildings based on search query\n const filterBuildings = React.useCallback((searchQuery) => {\n if (!showDatabaseBuildings || !buildings || !searchQuery || searchQuery.length < 3) return []\n\n const lowerQuery = searchQuery.toLowerCase()\n\n if (Array.isArray(buildings) && buildings.length > 0) {\n return buildings.filter((building) => {\n return (\n (building.buildingName && building.buildingName.toLowerCase().includes(lowerQuery))\n || (building.buildingAddress && building.buildingAddress.toLowerCase().includes(lowerQuery))\n || (building.buildingMunicipality && building.buildingMunicipality.toLowerCase().includes(lowerQuery))\n || (building.buildingCountrySubdivision && building.buildingCountrySubdivision.toLowerCase().includes(lowerQuery))\n )\n }).slice(0, 3) // Limit to 3 results\n }\n return []\n }, [buildings, showDatabaseBuildings])\n\n // Debounce the API request to avoid rate limiting and excessive requests\n React.useEffect(() => {\n if (debounceRef.current) {\n clearTimeout(debounceRef.current)\n }\n\n const fetchDebounced = async () => {\n if (!query || query.length < 3) {\n setSuggestions([])\n setBuildingResults([])\n setLoading(false)\n return\n }\n\n setLoading(true)\n try {\n // Filter buildings from our database only if enabled\n if (showDatabaseBuildings) {\n const filteredBuildings = filterBuildings(query)\n setBuildingResults(filteredBuildings)\n }\n\n // Fetch geocoding suggestions\n const geocodeResults = await fetchSuggestions(query, organizationCountry)\n\n // Deduplicate geocode results based on name and region\n const deduplicatedResults = geocodeResults.reduce((acc, feature) => {\n const location = parseLocation(feature)\n // Create a unique key based on name and region (case-insensitive)\n const key = `${location.name?.toLowerCase() || ''}_${location.region?.toLowerCase() || ''}`\n\n // Only add if we haven't seen this combination before\n if (!acc.seen.has(key)) {\n acc.seen.add(key)\n acc.features.push(feature)\n }\n\n return acc\n }, { seen: new Set(), features: [] })\n\n setSuggestions(deduplicatedResults.features)\n }\n catch (error) {\n console.error('Error fetching suggestions:', error)\n setSuggestions([])\n }\n finally {\n setLoading(false)\n }\n }\n\n debounceRef.current = setTimeout(() => { void fetchDebounced() }, 300) // Increased debounce time for better API rate limiting\n\n return () => {\n if (debounceRef.current) clearTimeout(debounceRef.current)\n }\n }, [query, filterBuildings, showDatabaseBuildings])\n\n // Handle click outside to close suggestions\n React.useEffect(() => {\n const handleClickOutside = (event) => {\n if (suggestionsRef.current && !suggestionsRef.current.contains(event.target)\n && inputRef.current && !inputRef.current.contains(event.target) // Don't close if alwaysExpanded is true\n && !alwaysExpanded) {\n setFocused(false)\n }\n }\n\n document.addEventListener('mousedown', handleClickOutside)\n return () => {\n document.removeEventListener('mousedown', handleClickOutside)\n }\n }, [alwaysExpanded])\n\n // Handle suggestion selection\n const handleSelectSuggestion = (feature, type = '') => {\n setQuery('') // Clear the input field\n setSuggestions([])\n setBuildingResults([])\n if (!alwaysExpanded) {\n setFocused(false)\n }\n\n const syncUrl = () => { if (map) writeLocationParams(map, labelsFor(feature, type)) }\n // handleLocationSelect will automatically remove any existing marker and add a new one\n const addressData = handleLocationSelect(feature, map, type, { onMoveEnd: syncUrl })\n\n const address = addressData.formatted_address || feature.properties?.label || ''\n setAddress(address)\n setSelectedAddress(addressData)\n\n if (onSelect) onSelect(addressData)\n\n if (mapDispatch && currentLocation && addressData.coordinates) {\n const [lng, lat] = addressData.coordinates\n const labels = labelsFor(feature, type)\n const newCurrentLocation: CurrentLocation = {\n ...currentLocation,\n municipality: labels.municipality ?? '',\n countrySubdivision: labels.countrySubdivision ?? '',\n address: labels.address ?? '',\n lng,\n lat,\n }\n mapDispatch({ type: 'UPDATE_LOCATION', payload: { currentLocation: newCurrentLocation } })\n }\n }\n\n // Handle expand of menubar to display search input\n const handleExpand = () => {\n if (alwaysExpanded) return // Don't allow toggling if always expanded\n\n setIsExpanded(!isExpanded)\n if (isExpanded) {\n setFocused(false)\n setQuery('') // clear input and suggestions when collapsed\n setSuggestions([])\n setBuildingResults([])\n }\n else {\n setFocused(true)\n setTimeout(() => {\n inputRef.current?.focus()\n }, 100) // Small delay to ensure the input is rendered\n }\n }\n\n return (\n <Command>\n {/* Search input + button */}\n <div className={`flex flex-row justify-start items-center w-full h-auto `}>\n {!alwaysExpanded && (\n <Button\n variant=\"ghost\"\n size=\"icon\"\n onClick={handleExpand}\n className=\"opacity-70 w-6 justify-end hover:opacity-100 transition-opacity duration-200 hover:bg-transparent\"\n >\n <Search />\n </Button>\n )}\n {alwaysExpanded && (\n <Search className=\"h-4 w-4 opacity-50\" />\n )}\n <Input\n ref={inputRef}\n type=\"text\"\n value={query}\n onChange={e => setQuery(e.target.value)}\n onFocus={() => setFocused(true)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n inputRef.current?.blur()\n }\n }}\n placeholder={alwaysExpanded ? t('placeholder1') : t('placeholder2')}\n className={`border-none focus-visible:ring-transparent text-sm transition-all ease-in-out duration-200 ${\n alwaysExpanded || isExpanded ? 'w-full' : 'w-0 p-0'\n }`}\n />\n </div>\n\n {focused && (loading || buildingResults.length > 0 || suggestions.length > 0) && (\n <div ref={suggestionsRef}>\n <Separator />\n <CommandList>\n {!loading && buildingResults.length === 0 && suggestions.length === 0 && query.length >= 3 && (\n <CommandEmpty>{showDatabaseBuildings ? t('noResults') : t('noAddresses')}</CommandEmpty>\n )}\n\n {loading && (\n <CommandEmpty><LoadingSpinner /></CommandEmpty>\n )}\n\n {/* Database Buildings section - only show if enabled */}\n {showDatabaseBuildings && !loading && buildingResults.length > 0 && (\n <CommandGroup heading={t('buildingHeader')}>\n {buildingResults.map((building) => {\n const buildingFeature = buildingToFeature(building)\n\n return (\n <CommandItem\n key={`building-${building.id}`}\n onSelect={() => handleSelectSuggestion(buildingFeature, 'dbBuilding')}\n className=\"cursor-pointer\"\n >\n <div className=\"font-medium\">{building.buildingName}</div>\n <div className=\"text-sm text-muted-foreground\">\n {building.buildingAddress}\n </div>\n </CommandItem>\n )\n })}\n </CommandGroup>\n )}\n\n {/* Separator between sections if both have results */}\n {showDatabaseBuildings && buildingResults.length > 0 && suggestions.length > 0 && (\n <CommandSeparator />\n )}\n\n {/* Geocoder suggestions section */}\n {!loading && suggestions.length > 0 && (\n <CommandGroup heading={showDatabaseBuildings ? t('suggestionsHeader') : undefined}>\n {suggestions.map((feature) => {\n const location = parseLocation(feature)\n const uniqueKey = feature.properties?.gid\n || `${feature.properties?.name}-${feature.geometry?.coordinates?.[0]}-${feature.geometry?.coordinates?.[1]}`\n\n return (\n <CommandItem\n key={uniqueKey}\n onSelect={() => handleSelectSuggestion(feature)}\n className=\"cursor-pointer\"\n >\n <div className=\"font-medium\">{location.name}</div>\n <div className=\"text-sm text-muted-foreground\">{location.region}</div>\n </CommandItem>\n )\n })}\n </CommandGroup>\n )}\n </CommandList>\n </div>\n )}\n </Command>\n )\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AA8OU,SAQM,KARN;AAxOV,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,YAAY,WAAW;AAGvB,SAAS,oBAAoB;AAC7B,SAAS,iCAAiC;AAC1C,SAAS,kBAAkB;AAK3B,SAAS,cAAc;AACvB,SAAS,SAAS,aAAa,cAAc,cAAc,aAAa,wBAAwB;AAChG,SAAS,aAAa;AACtB,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;AAO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,WAAU,eAAe,mBAAS,cAAa;AAAA,gBACpD,oBAAC,SAAI,WAAU,iCACZ,mBAAS,iBACZ;AAAA;AAAA;AAAA,YAPK,YAAY,SAAS,EAAE;AAAA,UAQ9B;AAAA,QAEJ,CAAC,GACH;AAAA,QAID,yBAAyB,gBAAgB,SAAS,KAAK,YAAY,SAAS,KAC3E,oBAAC,oBAAiB;AAAA,QAInB,CAAC,WAAW,YAAY,SAAS,KAChC,oBAAC,gBAAa,SAAS,wBAAwB,EAAE,mBAAmB,IAAI,QACrE,sBAAY,IAAI,CAAC,YAAY;AAxTlD;AAyTsB,gBAAM,WAAW,cAAc,OAAO;AACtC,gBAAM,cAAY,aAAQ,eAAR,mBAAoB,QACjC,IAAG,aAAQ,eAAR,mBAAoB,IAAI,KAAI,mBAAQ,aAAR,mBAAkB,gBAAlB,mBAAgC,EAAE,KAAI,mBAAQ,aAAR,mBAAkB,gBAAlB,mBAAgC,EAAE;AAE5G,iBACE;AAAA,YAAC;AAAA;AAAA,cAEC,UAAU,MAAM,uBAAuB,OAAO;AAAA,cAC9C,WAAU;AAAA,cAEV;AAAA,oCAAC,SAAI,WAAU,eAAe,mBAAS,MAAK;AAAA,gBAC5C,oBAAC,SAAI,WAAU,iCAAiC,mBAAS,QAAO;AAAA;AAAA;AAAA,YAL3D;AAAA,UAMP;AAAA,QAEJ,CAAC,GACH;AAAA,SAEJ;AAAA,OACF;AAAA,KAEJ;AAER;","names":["address"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/CountryLayer/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/CountryLayer/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAa9B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAA;AAWtE,eAAO,MAAM,sBAAsB,2iBAOzB,CAAA;AAEV,eAAO,MAAM,wBAAwB,gFAI3B,CAAA;AAsHV,eAAO,MAAM,YAAY,GAAI,+BAA+B;IAAE,YAAY,CAAC,EAAE,YAAY,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,sBA4GhH,CAAA"}
|