@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
|
@@ -21,11 +21,12 @@ var __spreadValues = (a, b) => {
|
|
|
21
21
|
};
|
|
22
22
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
23
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
24
|
-
import { useSearchParams
|
|
24
|
+
import { useSearchParams } from "next/navigation";
|
|
25
25
|
import * as React from "react";
|
|
26
26
|
import { Source, Layer } from "react-map-gl/maplibre";
|
|
27
27
|
import { MapContext } from "../../../../../../../store/Map/context";
|
|
28
28
|
import { maptilerKeyForRequest } from "../../../../utils/mapStyleSpec";
|
|
29
|
+
import { replaceUrlParams } from "../../../../utils/urlLocation/locationParams";
|
|
29
30
|
import { hexToRgba, buildSubdivisionUrl } from "./countryLayerUtils";
|
|
30
31
|
import { useCameraSubdivision } from "./useCameraSubdivision";
|
|
31
32
|
import { useSubdivisionHover } from "./useSubdivisionHover";
|
|
@@ -168,7 +169,6 @@ const CountryLayer = ({ organization, maptilerKey }) => {
|
|
|
168
169
|
const { state: mapState, dispatch: mapDispatch } = React.useContext(MapContext);
|
|
169
170
|
const { map, currentLocation } = mapState.map;
|
|
170
171
|
const searchParams = useSearchParams();
|
|
171
|
-
const router = useRouter();
|
|
172
172
|
const countryCode = ((organization == null ? void 0 : organization.country) || "CA").toUpperCase();
|
|
173
173
|
const borderColor = hexToRgba((organization == null ? void 0 : organization.mainColor) || DEFAULT_BORDER_COLOR, 0.7);
|
|
174
174
|
const subdivisionUrl = buildSubdivisionUrl(countryCode);
|
|
@@ -210,10 +210,11 @@ const CountryLayer = ({ organization, maptilerKey }) => {
|
|
|
210
210
|
currentLocation: __spreadProps(__spreadValues({}, currentLocation != null ? currentLocation : {}), { countrySubdivision: code })
|
|
211
211
|
}
|
|
212
212
|
});
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
213
|
+
replaceUrlParams((params) => {
|
|
214
|
+
params.set("countrySubdivision", code);
|
|
215
|
+
return params;
|
|
216
|
+
});
|
|
217
|
+
}, [currentLocation, mapDispatch]);
|
|
217
218
|
useCameraSubdivision({
|
|
218
219
|
map,
|
|
219
220
|
layerId: SUBDIVISION_FILL_ID,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/CountryLayer/index.tsx"],"sourcesContent":["\"use client\"\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { useSearchParams, useRouter } from 'next/navigation'\nimport * as React from 'react'\nimport { Source, Layer } from 'react-map-gl/maplibre'\n\nimport { MapContext } from '../../../../../../../store/Map/context'\n\nimport { maptilerKeyForRequest } from '../../../../utils/mapStyleSpec'\n\nimport { hexToRgba, buildSubdivisionUrl } from './countryLayerUtils'\nimport { useCameraSubdivision } from './useCameraSubdivision'\nimport { useSubdivisionHover } from './useSubdivisionHover'\n\nimport type { Organization } from '../../../../../../../types/dbTypes'\n\nconst DEFAULT_BORDER_COLOR = '#73cee2'\nconst BOUNDARIES_SOURCE_ID = 'openmaptiles-boundaries'\nconst SUBDIVISION_SOURCE_ID = 'admin-subdivisions-source'\nconst SUBDIVISION_FILL_ID = 'admin-subdivisions-fill'\nconst SUBDIVISION_LINE_ID = 'admin-subdivisions-line'\nconst SUBDIVISION_LINE_MAX_ZOOM = 10\n\nconst HOVERED = ['boolean', ['feature-state', 'hover'], false] as const\n\nexport const SUBDIVISION_LINE_WIDTH = [\n 'interpolate', ['linear'], ['zoom'],\n 4, ['case', HOVERED, 0.5, 0.5],\n 8, ['case', HOVERED, 1.4, 1.4],\n 10, ['case', HOVERED, 3, 1.7],\n 14, ['case', HOVERED, 4.6, 2.4],\n 15, ['case', HOVERED, 5, 2.4],\n] as const\n// The border only helps while picking a subdivision; past zoom 9 the fill still hit-tests without it.\nexport const SUBDIVISION_LINE_OPACITY = [\n 'interpolate', ['linear'], ['zoom'],\n 9, 1,\n 9.5, 0,\n] as const\n\nconst GLOBAL_LAYER_IDS = [\n 'global-borders-country',\n 'global-labels-country',\n 'global-labels-state',\n 'global-labels-city',\n] as const\n\nfunction addGlobalBorderLayer(map: any, color: string, maptilerKey?: string) {\n const key = maptilerKeyForRequest(maptilerKey)\n if (!key) return\n\n try {\n if (!map.getSource(BOUNDARIES_SOURCE_ID)) {\n map.addSource(BOUNDARIES_SOURCE_ID, {\n type: 'vector',\n url: `https://api.maptiler.com/tiles/v3/tiles.json?key=${key}`,\n })\n }\n\n // Country borders — visible at all zooms, slightly thinner up close where states take over.\n if (!map.getLayer('global-borders-country')) {\n map.addLayer({\n id: 'global-borders-country',\n type: 'line',\n source: BOUNDARIES_SOURCE_ID,\n 'source-layer': 'boundary',\n filter: ['all', ['==', 'admin_level', 2], ['==', 'maritime', 0]],\n layout: { 'line-cap': 'round', 'line-join': 'round' },\n paint: {\n 'line-color': color,\n 'line-width': { base: 1, stops: [[0, 0.8], [4, 1.4], [10, 1.4], [14, 1]] },\n },\n })\n }\n\n // Country labels — small/global up to zoom ~6, gone by 8.\n if (!map.getLayer('global-labels-country')) {\n map.addLayer({\n id: 'global-labels-country',\n type: 'symbol',\n source: BOUNDARIES_SOURCE_ID,\n 'source-layer': 'place',\n filter: ['==', 'class', 'country'],\n minzoom: 1,\n maxzoom: 8,\n layout: {\n 'text-field': ['coalesce', ['get', 'name:latin'], ['get', 'name']],\n 'text-font': ['Noto Sans Regular'],\n 'text-size': { base: 1, stops: [[1, 10], [4, 13], [6, 16]] },\n 'text-letter-spacing': 0.1,\n 'text-max-width': 8,\n 'text-transform': 'uppercase',\n },\n paint: {\n 'text-color': '#ffffff',\n 'text-halo-color': 'rgba(0,0,0,0.7)',\n 'text-halo-width': 1.2,\n 'text-opacity': { base: 1, stops: [[5, 1], [7, 0]] },\n },\n })\n }\n\n // State / province labels — cover zoom 3–8.\n if (!map.getLayer('global-labels-state')) {\n map.addLayer({\n id: 'global-labels-state',\n type: 'symbol',\n source: BOUNDARIES_SOURCE_ID,\n 'source-layer': 'place',\n filter: ['in', 'class', 'state', 'province'],\n minzoom: 3,\n maxzoom: 9,\n layout: {\n 'text-field': ['coalesce', ['get', 'name:latin'], ['get', 'name']],\n 'text-font': ['Noto Sans Regular'],\n 'text-size': { base: 1, stops: [[3, 9], [6, 12], [8, 14]] },\n 'text-letter-spacing': 0.05,\n 'text-max-width': 8,\n },\n paint: {\n 'text-color': '#e8e8e8',\n 'text-halo-color': 'rgba(0,0,0,0.6)',\n 'text-halo-width': 1,\n 'text-opacity': { base: 1, stops: [[3, 0], [4, 1], [8, 1], [9, 0]] },\n },\n })\n }\n\n // Major city labels (rank ≤ 4 = most prominent cities) — appear when zoomed in past country level.\n if (!map.getLayer('global-labels-city')) {\n map.addLayer({\n id: 'global-labels-city',\n type: 'symbol',\n source: BOUNDARIES_SOURCE_ID,\n 'source-layer': 'place',\n filter: ['in', 'class', 'city', 'town'],\n minzoom: 5,\n maxzoom: 13,\n layout: {\n 'text-field': ['coalesce', ['get', 'name:latin'], ['get', 'name']],\n 'text-font': ['Noto Sans Regular'],\n 'text-size': { base: 1, stops: [[5, 10], [9, 13], [12, 15]] },\n 'text-max-width': 8,\n },\n paint: {\n 'text-color': '#dcdcdc',\n 'text-halo-color': 'rgba(0,0,0,0.7)',\n 'text-halo-width': 1.1,\n },\n })\n }\n } catch {\n // style may be in a transitional state\n }\n}\n\nexport const CountryLayer = ({ organization, maptilerKey }: { organization?: Organization; maptilerKey?: string }) => {\n const { state: mapState, dispatch: mapDispatch } = React.useContext(MapContext)\n const { map, currentLocation } = mapState.map\n const searchParams = useSearchParams()\n const router = useRouter()\n\n const countryCode = (organization?.country || 'CA').toUpperCase()\n const borderColor = hexToRgba((organization?.mainColor as string) || DEFAULT_BORDER_COLOR, 0.7)\n const subdivisionUrl = buildSubdivisionUrl(countryCode)\n\n // Re-added on every style swap: setStyle drops imperatively added layers.\n React.useEffect(() => {\n if (!map) return\n const addNow = () => addGlobalBorderLayer(map, borderColor, maptilerKey)\n if (map.isStyleLoaded()) addNow()\n map.on('styledata', addNow)\n return () => {\n try {\n map.off('styledata', addNow)\n for (const id of GLOBAL_LAYER_IDS) {\n if (map.getLayer(id)) map.removeLayer(id)\n }\n } catch {\n // map may be destroyed\n }\n }\n }, [map, borderColor, maptilerKey])\n\n // If the org already has a fixed subdivision or municipality, lock them in and skip camera tracking\n const orgHasLocation = !!(organization?.countrySubdivision || organization?.municipality)\n\n // A selected building owns the location params; camera tracking would overwrite them on the first pan.\n const buildingOwnsLocation = !!searchParams.get('buildingId')\n\n // When org has fixed location values, push them into currentLocation once\n React.useEffect(() => {\n if (!orgHasLocation) return\n mapDispatch({\n type: 'UPDATE_LOCATION',\n payload: {\n currentLocation: {\n ...(currentLocation ?? {}),\n countrySubdivision: organization?.countrySubdivision ?? currentLocation?.countrySubdivision,\n municipality: organization?.municipality ?? currentLocation?.municipality,\n } as any,\n },\n })\n\n }, [orgHasLocation])\n\n const commitSubdivision = React.useCallback((code: string) => {\n if (code === (currentLocation?.countrySubdivision || null)) return\n\n mapDispatch({\n type: 'UPDATE_LOCATION',\n payload: {\n currentLocation: { ...(currentLocation ?? {}), countrySubdivision: code } as any,\n },\n })\n\n const params = new URLSearchParams(searchParams.toString())\n params.set('countrySubdivision', code)\n router.replace(`?${params.toString()}`, { scroll: false })\n }, [currentLocation, mapDispatch, router, searchParams])\n\n useCameraSubdivision({\n map,\n layerId: SUBDIVISION_FILL_ID,\n sourceId: SUBDIVISION_SOURCE_ID,\n enabled: !orgHasLocation && !buildingOwnsLocation,\n onResolve: commitSubdivision,\n })\n\n useSubdivisionHover({\n map,\n layerId: SUBDIVISION_FILL_ID,\n sourceId: SUBDIVISION_SOURCE_ID,\n enabled: !orgHasLocation,\n })\n\n if (orgHasLocation) return null\n\n return (\n <Source\n id={SUBDIVISION_SOURCE_ID}\n type=\"geojson\"\n data={subdivisionUrl}\n generateId\n >\n {/* Zero opacity, never visible: this is what hit-tests the camera target and the pointer. */}\n <Layer\n id={SUBDIVISION_FILL_ID}\n type=\"fill\"\n paint={{ 'fill-color': borderColor, 'fill-opacity': 0 }}\n />\n <Layer\n id={SUBDIVISION_LINE_ID}\n type=\"line\"\n maxzoom={SUBDIVISION_LINE_MAX_ZOOM}\n layout={{ 'line-cap': 'round', 'line-join': 'round' }}\n paint={{\n 'line-color': borderColor,\n 'line-width': SUBDIVISION_LINE_WIDTH as never,\n 'line-opacity': SUBDIVISION_LINE_OPACITY as never,\n }}\n />\n </Source>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkPI,SAOE,KAPF;AA7OJ,SAAS,iBAAiB,iBAAiB;AAC3C,YAAY,WAAW;AACvB,SAAS,QAAQ,aAAa;AAE9B,SAAS,kBAAkB;AAE3B,SAAS,6BAA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YAClB;AAAA;AAAA,QACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/CountryLayer/index.tsx"],"sourcesContent":["\"use client\"\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { useSearchParams } from 'next/navigation'\nimport * as React from 'react'\nimport { Source, Layer } from 'react-map-gl/maplibre'\n\nimport { MapContext } from '../../../../../../../store/Map/context'\n\nimport { maptilerKeyForRequest } from '../../../../utils/mapStyleSpec'\n\nimport { replaceUrlParams } from '../../../../utils/urlLocation/locationParams'\n\nimport { hexToRgba, buildSubdivisionUrl } from './countryLayerUtils'\nimport { useCameraSubdivision } from './useCameraSubdivision'\nimport { useSubdivisionHover } from './useSubdivisionHover'\n\nimport type { Organization } from '../../../../../../../types/dbTypes'\n\nconst DEFAULT_BORDER_COLOR = '#73cee2'\nconst BOUNDARIES_SOURCE_ID = 'openmaptiles-boundaries'\nconst SUBDIVISION_SOURCE_ID = 'admin-subdivisions-source'\nconst SUBDIVISION_FILL_ID = 'admin-subdivisions-fill'\nconst SUBDIVISION_LINE_ID = 'admin-subdivisions-line'\nconst SUBDIVISION_LINE_MAX_ZOOM = 10\n\nconst HOVERED = ['boolean', ['feature-state', 'hover'], false] as const\n\nexport const SUBDIVISION_LINE_WIDTH = [\n 'interpolate', ['linear'], ['zoom'],\n 4, ['case', HOVERED, 0.5, 0.5],\n 8, ['case', HOVERED, 1.4, 1.4],\n 10, ['case', HOVERED, 3, 1.7],\n 14, ['case', HOVERED, 4.6, 2.4],\n 15, ['case', HOVERED, 5, 2.4],\n] as const\n// The border only helps while picking a subdivision; past zoom 9 the fill still hit-tests without it.\nexport const SUBDIVISION_LINE_OPACITY = [\n 'interpolate', ['linear'], ['zoom'],\n 9, 1,\n 9.5, 0,\n] as const\n\nconst GLOBAL_LAYER_IDS = [\n 'global-borders-country',\n 'global-labels-country',\n 'global-labels-state',\n 'global-labels-city',\n] as const\n\nfunction addGlobalBorderLayer(map: any, color: string, maptilerKey?: string) {\n const key = maptilerKeyForRequest(maptilerKey)\n if (!key) return\n\n try {\n if (!map.getSource(BOUNDARIES_SOURCE_ID)) {\n map.addSource(BOUNDARIES_SOURCE_ID, {\n type: 'vector',\n url: `https://api.maptiler.com/tiles/v3/tiles.json?key=${key}`,\n })\n }\n\n // Country borders — visible at all zooms, slightly thinner up close where states take over.\n if (!map.getLayer('global-borders-country')) {\n map.addLayer({\n id: 'global-borders-country',\n type: 'line',\n source: BOUNDARIES_SOURCE_ID,\n 'source-layer': 'boundary',\n filter: ['all', ['==', 'admin_level', 2], ['==', 'maritime', 0]],\n layout: { 'line-cap': 'round', 'line-join': 'round' },\n paint: {\n 'line-color': color,\n 'line-width': { base: 1, stops: [[0, 0.8], [4, 1.4], [10, 1.4], [14, 1]] },\n },\n })\n }\n\n // Country labels — small/global up to zoom ~6, gone by 8.\n if (!map.getLayer('global-labels-country')) {\n map.addLayer({\n id: 'global-labels-country',\n type: 'symbol',\n source: BOUNDARIES_SOURCE_ID,\n 'source-layer': 'place',\n filter: ['==', 'class', 'country'],\n minzoom: 1,\n maxzoom: 8,\n layout: {\n 'text-field': ['coalesce', ['get', 'name:latin'], ['get', 'name']],\n 'text-font': ['Noto Sans Regular'],\n 'text-size': { base: 1, stops: [[1, 10], [4, 13], [6, 16]] },\n 'text-letter-spacing': 0.1,\n 'text-max-width': 8,\n 'text-transform': 'uppercase',\n },\n paint: {\n 'text-color': '#ffffff',\n 'text-halo-color': 'rgba(0,0,0,0.7)',\n 'text-halo-width': 1.2,\n 'text-opacity': { base: 1, stops: [[5, 1], [7, 0]] },\n },\n })\n }\n\n // State / province labels — cover zoom 3–8.\n if (!map.getLayer('global-labels-state')) {\n map.addLayer({\n id: 'global-labels-state',\n type: 'symbol',\n source: BOUNDARIES_SOURCE_ID,\n 'source-layer': 'place',\n filter: ['in', 'class', 'state', 'province'],\n minzoom: 3,\n maxzoom: 9,\n layout: {\n 'text-field': ['coalesce', ['get', 'name:latin'], ['get', 'name']],\n 'text-font': ['Noto Sans Regular'],\n 'text-size': { base: 1, stops: [[3, 9], [6, 12], [8, 14]] },\n 'text-letter-spacing': 0.05,\n 'text-max-width': 8,\n },\n paint: {\n 'text-color': '#e8e8e8',\n 'text-halo-color': 'rgba(0,0,0,0.6)',\n 'text-halo-width': 1,\n 'text-opacity': { base: 1, stops: [[3, 0], [4, 1], [8, 1], [9, 0]] },\n },\n })\n }\n\n // Major city labels (rank ≤ 4 = most prominent cities) — appear when zoomed in past country level.\n if (!map.getLayer('global-labels-city')) {\n map.addLayer({\n id: 'global-labels-city',\n type: 'symbol',\n source: BOUNDARIES_SOURCE_ID,\n 'source-layer': 'place',\n filter: ['in', 'class', 'city', 'town'],\n minzoom: 5,\n maxzoom: 13,\n layout: {\n 'text-field': ['coalesce', ['get', 'name:latin'], ['get', 'name']],\n 'text-font': ['Noto Sans Regular'],\n 'text-size': { base: 1, stops: [[5, 10], [9, 13], [12, 15]] },\n 'text-max-width': 8,\n },\n paint: {\n 'text-color': '#dcdcdc',\n 'text-halo-color': 'rgba(0,0,0,0.7)',\n 'text-halo-width': 1.1,\n },\n })\n }\n } catch {\n // style may be in a transitional state\n }\n}\n\nexport const CountryLayer = ({ organization, maptilerKey }: { organization?: Organization; maptilerKey?: string }) => {\n const { state: mapState, dispatch: mapDispatch } = React.useContext(MapContext)\n const { map, currentLocation } = mapState.map\n const searchParams = useSearchParams()\n\n const countryCode = (organization?.country || 'CA').toUpperCase()\n const borderColor = hexToRgba((organization?.mainColor as string) || DEFAULT_BORDER_COLOR, 0.7)\n const subdivisionUrl = buildSubdivisionUrl(countryCode)\n\n // Re-added on every style swap: setStyle drops imperatively added layers.\n React.useEffect(() => {\n if (!map) return\n const addNow = () => addGlobalBorderLayer(map, borderColor, maptilerKey)\n if (map.isStyleLoaded()) addNow()\n map.on('styledata', addNow)\n return () => {\n try {\n map.off('styledata', addNow)\n for (const id of GLOBAL_LAYER_IDS) {\n if (map.getLayer(id)) map.removeLayer(id)\n }\n } catch {\n // map may be destroyed\n }\n }\n }, [map, borderColor, maptilerKey])\n\n // If the org already has a fixed subdivision or municipality, lock them in and skip camera tracking\n const orgHasLocation = !!(organization?.countrySubdivision || organization?.municipality)\n\n // A selected building owns the location params; camera tracking would overwrite them on the first pan.\n const buildingOwnsLocation = !!searchParams.get('buildingId')\n\n // When org has fixed location values, push them into currentLocation once\n React.useEffect(() => {\n if (!orgHasLocation) return\n mapDispatch({\n type: 'UPDATE_LOCATION',\n payload: {\n currentLocation: {\n ...(currentLocation ?? {}),\n countrySubdivision: organization?.countrySubdivision ?? currentLocation?.countrySubdivision,\n municipality: organization?.municipality ?? currentLocation?.municipality,\n } as any,\n },\n })\n\n }, [orgHasLocation])\n\n const commitSubdivision = React.useCallback((code: string) => {\n if (code === (currentLocation?.countrySubdivision || null)) return\n\n mapDispatch({\n type: 'UPDATE_LOCATION',\n payload: {\n currentLocation: { ...(currentLocation ?? {}), countrySubdivision: code } as any,\n },\n })\n\n replaceUrlParams(params => {\n params.set('countrySubdivision', code)\n return params\n })\n }, [currentLocation, mapDispatch])\n\n useCameraSubdivision({\n map,\n layerId: SUBDIVISION_FILL_ID,\n sourceId: SUBDIVISION_SOURCE_ID,\n enabled: !orgHasLocation && !buildingOwnsLocation,\n onResolve: commitSubdivision,\n })\n\n useSubdivisionHover({\n map,\n layerId: SUBDIVISION_FILL_ID,\n sourceId: SUBDIVISION_SOURCE_ID,\n enabled: !orgHasLocation,\n })\n\n if (orgHasLocation) return null\n\n return (\n <Source\n id={SUBDIVISION_SOURCE_ID}\n type=\"geojson\"\n data={subdivisionUrl}\n generateId\n >\n {/* Zero opacity, never visible: this is what hit-tests the camera target and the pointer. */}\n <Layer\n id={SUBDIVISION_FILL_ID}\n type=\"fill\"\n paint={{ 'fill-color': borderColor, 'fill-opacity': 0 }}\n />\n <Layer\n id={SUBDIVISION_LINE_ID}\n type=\"line\"\n maxzoom={SUBDIVISION_LINE_MAX_ZOOM}\n layout={{ 'line-cap': 'round', 'line-join': 'round' }}\n paint={{\n 'line-color': borderColor,\n 'line-width': SUBDIVISION_LINE_WIDTH as never,\n 'line-opacity': SUBDIVISION_LINE_OPACITY as never,\n }}\n />\n </Source>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoPI,SAOE,KAPF;AA/OJ,SAAS,uBAAuB;AAChC,YAAY,WAAW;AACvB,SAAS,QAAQ,aAAa;AAE9B,SAAS,kBAAkB;AAE3B,SAAS,6BAA6B;AAEtC,SAAS,wBAAwB;AAEjC,SAAS,WAAW,2BAA2B;AAC/C,SAAS,4BAA4B;AACrC,SAAS,2BAA2B;AAIpC,MAAM,uBAAuB;AAC7B,MAAM,uBAAuB;AAC7B,MAAM,wBAAwB;AAC9B,MAAM,sBAAsB;AAC5B,MAAM,sBAAsB;AAC5B,MAAM,4BAA4B;AAElC,MAAM,UAAU,CAAC,WAAW,CAAC,iBAAiB,OAAO,GAAG,KAAK;AAEtD,MAAM,yBAAyB;AAAA,EACpC;AAAA,EAAe,CAAC,QAAQ;AAAA,EAAG,CAAC,MAAM;AAAA,EAClC;AAAA,EAAG,CAAC,QAAQ,SAAS,KAAK,GAAG;AAAA,EAC7B;AAAA,EAAG,CAAC,QAAQ,SAAS,KAAK,GAAG;AAAA,EAC7B;AAAA,EAAI,CAAC,QAAQ,SAAS,GAAG,GAAG;AAAA,EAC5B;AAAA,EAAI,CAAC,QAAQ,SAAS,KAAK,GAAG;AAAA,EAC9B;AAAA,EAAI,CAAC,QAAQ,SAAS,GAAG,GAAG;AAC9B;AAEO,MAAM,2BAA2B;AAAA,EACtC;AAAA,EAAe,CAAC,QAAQ;AAAA,EAAG,CAAC,MAAM;AAAA,EAClC;AAAA,EAAG;AAAA,EACH;AAAA,EAAK;AACP;AAEA,MAAM,mBAAmB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,SAAS,qBAAq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AE,cAAc,aAAa,gBAAgB,EAAE;AAAA;AAAA,QACxD;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,IAAI;AAAA,YACJ,MAAK;AAAA,YACL,SAAS;AAAA,YACT,QAAQ,EAAE,YAAY,SAAS,aAAa,QAAQ;AAAA,YACpD,OAAO;AAAA,cACL,cAAc;AAAA,cACd,cAAc;AAAA,cACd,gBAAgB;AAAA,YAClB;AAAA;AAAA,QACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocationSettings.d.ts","sourceRoot":"","sources":["../../../../../../../../../../src/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/LocationSettings.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"LocationSettings.d.ts","sourceRoot":"","sources":["../../../../../../../../../../src/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/LocationSettings.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAa/B,wBAAgB,gBAAgB,CAAC,EAAE,WAAW,EAAE,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,qBAiSzE"}
|
package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/LocationSettings.js
CHANGED
|
@@ -29,6 +29,10 @@ import { MapContext } from "../../../../../../../../store";
|
|
|
29
29
|
import { Input } from "../../../../../../../ui/";
|
|
30
30
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../../../../../../../ui/Select";
|
|
31
31
|
import { SettingsSection } from "../../../../../../../ui/ViewerSidebar/SettingsSection";
|
|
32
|
+
import { searchPlace } from "../../../../../utils/geocoding";
|
|
33
|
+
import { clearFinerLabels, flyAndSyncUrl, labelsFromParams } from "../../../../../utils/urlLocation/locationParams";
|
|
34
|
+
import { DEFAULT_LEVEL_ZOOM } from "../../../../../utils/urlLocation/locationTarget";
|
|
35
|
+
import { resolveLocationTarget } from "../../../../../utils/urlLocation/resolveLocationTarget";
|
|
32
36
|
function LocationSettings({ countryCode }) {
|
|
33
37
|
const [municipalityInput, setMunicipalityInput] = useState("");
|
|
34
38
|
const [municipalitySuggestions, setMunicipalitySuggestions] = useState([]);
|
|
@@ -51,25 +55,6 @@ function LocationSettings({ countryCode }) {
|
|
|
51
55
|
setMunicipality(currentLocation.municipality || "");
|
|
52
56
|
}
|
|
53
57
|
}, [currentLocation]);
|
|
54
|
-
const geocodeLocation = async (query) => {
|
|
55
|
-
try {
|
|
56
|
-
const response = await fetch(
|
|
57
|
-
`https://nominatim.openstreetmap.org/search?format=json&q=${encodeURIComponent(query)}&limit=1&countrycodes=${orgCountryCode}`
|
|
58
|
-
);
|
|
59
|
-
const data = await response.json();
|
|
60
|
-
if (data && data.length > 0) {
|
|
61
|
-
const result = data[0];
|
|
62
|
-
return {
|
|
63
|
-
lat: parseFloat(result.lat),
|
|
64
|
-
lng: parseFloat(result.lon)
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
return null;
|
|
68
|
-
} catch (error) {
|
|
69
|
-
console.error("Geocoding error:", error);
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
58
|
const onCountrySubdivisionChange = async (value) => {
|
|
74
59
|
setMunicipalityInput("");
|
|
75
60
|
setMunicipalitySuggestions([]);
|
|
@@ -83,14 +68,12 @@ function LocationSettings({ countryCode }) {
|
|
|
83
68
|
})
|
|
84
69
|
}
|
|
85
70
|
});
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
});
|
|
93
|
-
}
|
|
71
|
+
if (!map) return;
|
|
72
|
+
const params = new URLSearchParams(window.location.search);
|
|
73
|
+
params.set("countrySubdivision", value);
|
|
74
|
+
params.delete("municipality");
|
|
75
|
+
const resolved = await resolveLocationTarget(params, { searchPlace, countryCode: orgCountryCode });
|
|
76
|
+
if ((resolved == null ? void 0 : resolved.level) === "countrySubdivision") void flyAndSyncUrl(map, resolved.target, resolved.labels);
|
|
94
77
|
};
|
|
95
78
|
const onMunicipalityChange = async (e) => {
|
|
96
79
|
const value = e.target.value;
|
|
@@ -136,11 +119,8 @@ function LocationSettings({ countryCode }) {
|
|
|
136
119
|
});
|
|
137
120
|
setShowSuggestions(false);
|
|
138
121
|
if (map) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
zoom: 12,
|
|
142
|
-
essential: true
|
|
143
|
-
});
|
|
122
|
+
const labels = clearFinerLabels(__spreadProps(__spreadValues({}, labelsFromParams(new URLSearchParams(window.location.search))), { municipality: suggestion.name }), "municipality");
|
|
123
|
+
void flyAndSyncUrl(map, { center: [suggestion.lng, suggestion.lat], zoom: DEFAULT_LEVEL_ZOOM.municipality }, labels);
|
|
144
124
|
}
|
|
145
125
|
};
|
|
146
126
|
React.useEffect(() => {
|
package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/LocationSettings.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../../src/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/LocationSettings.tsx"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as LR from 'lucide-react'\nimport { useTranslations } from 'next-intl'\nimport * as React from \"react\";\nimport { useState } from 'react';\n\nimport { MapContext } from '../../../../../../../../store';\nimport { Input } from '../../../../../../../ui/';\nimport { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../../../../../../../ui/Select'\nimport { SettingsSection } from '../../../../../../../ui/ViewerSidebar/SettingsSection';\n\n\nexport function LocationSettings({ countryCode }: { countryCode?: string }) {\n // Municipality autocomplete state\n const [municipalityInput, setMunicipalityInput] = useState('');\n const [municipalitySuggestions, setMunicipalitySuggestions] = useState<Array<{ name: string, lat: number, lng: number }>>([]);\n const [showSuggestions, setShowSuggestions] = useState(false);\n // Translation\n const t = useTranslations('SettingsTab')\n const {dispatch: mapDispatch, state: mapState} = React.useContext(MapContext)\n const { currentLocation, map, countrySubdivisionsData } = mapState.map;\n const orgCountryCode = (countryCode || 'CA').toLowerCase()\n\n // Local input states for lat/lng/zoom\n const [currentLat, setCurrentLat] = React.useState<number>();\n const [currentLng, setCurrentLng] = React.useState<number>();\n const [currentZoom, setCurrentZoom] = React.useState<number>();\n const [countrySubdivision, setCountrySubdivision] = React.useState<string>('');\n const [municipality, setMunicipality] = React.useState<string>('');\n\n React.useEffect(() => {\n if (currentLocation) {\n setCurrentLat(currentLocation.lat);\n setCurrentLng(currentLocation.lng);\n setCurrentZoom(currentLocation.zoom);\n setCountrySubdivision(currentLocation.countrySubdivision || '');\n setMunicipality(currentLocation.municipality || '');\n }\n }, [currentLocation]);\n\n\n // Geocode helper\n const geocodeLocation = async (query: string) => {\n try {\n const response = await fetch(\n `https://nominatim.openstreetmap.org/search?` +\n `format=json&q=${encodeURIComponent(query)}&limit=1&countrycodes=${orgCountryCode}`\n );\n const data = await response.json();\n if (data && data.length > 0) {\n const result = data[0];\n return {\n lat: parseFloat(result.lat),\n lng: parseFloat(result.lon)\n };\n }\n return null;\n } catch (error) {\n console.error('Geocoding error:', error);\n return null;\n }\n };\n\n // Country subdivision change handler with geocoding\n const onCountrySubdivisionChange = async (value: string) => {\n // Clear municipality input and state\n setMunicipalityInput('');\n setMunicipalitySuggestions([]);\n setShowSuggestions(false);\n mapDispatch({\n type: 'UPDATE_LOCATION',\n payload: {\n currentLocation: {\n ...currentLocation,\n countrySubdivision: value,\n municipality: ''\n }\n }\n });\n\n // Geocode and navigate to country subdivision\n const location = await geocodeLocation(value);\n if (location && map) {\n map.flyTo({\n center: [location.lng, location.lat],\n zoom: 6,\n essential: true\n });\n }\n };\n\n // Municipality change handler with geocoding\n const onMunicipalityChange = async (e: React.ChangeEvent<HTMLInputElement>) => {\n const value = e.target.value;\n setMunicipalityInput(value);\n mapDispatch({\n type: 'UPDATE_LOCATION',\n payload: {\n currentLocation: {\n ...currentLocation,\n municipality: value\n }\n }\n });\n\n // Fetch municipality suggestions\n if (value.length > 2 && countrySubdivision) {\n const response = await fetch(\n `https://nominatim.openstreetmap.org/search?` +\n `format=json&q=${encodeURIComponent(value + ', ' + countrySubdivision)}&limit=5&countrycodes=${orgCountryCode}`\n );\n const data = await response.json();\n // Only show municipality results\n const filtered = data.filter((item: any) =>\n item.type === 'municipality' || item.class === 'boundary' && item.type === 'administrative'\n ).slice(0, 3);\n setMunicipalitySuggestions(filtered.map((item: any) => ({\n name: item.display_name.split(',')[0],\n lat: parseFloat(item.lat),\n lng: parseFloat(item.lon)\n })));\n setShowSuggestions(true);\n } else {\n setMunicipalitySuggestions([]);\n setShowSuggestions(false);\n }\n };\n\n // When a suggestion is selected, update and fly\n const onMunicipalitySuggestionSelect = (suggestion: { name: string, lat: number, lng: number }) => {\n setMunicipalityInput(suggestion.name);\n mapDispatch({\n type: 'UPDATE_LOCATION',\n payload: {\n currentLocation: {\n ...currentLocation,\n municipality: suggestion.name,\n lat: suggestion.lat,\n lng: suggestion.lng\n }\n }\n });\n setShowSuggestions(false);\n if (map) {\n map.flyTo({\n center: [suggestion.lng, suggestion.lat],\n zoom: 12,\n essential: true\n });\n }\n };\n\n React.useEffect(() => {\n if (!map) return;\n const handleMoveEnd = () => {\n const newCenter = map.getCenter();\n setCurrentLat(newCenter.lat);\n setCurrentLng(newCenter.lng);\n const newZoom = map.getZoom();\n setCurrentZoom(newZoom);\n };\n map.on('moveend', handleMoveEnd);\n return () => {\n map.off('moveend', handleMoveEnd);\n };\n }, [map]);\n\n // Early return if currentLocation is not yet initialized\n if (!currentLocation) {\n return null;\n }\n\n // Input change handlers (local state only)\n // If the input is changed by arrows (stepper), update instantly\n const onLatitudeInputChange = (e) => {\n setCurrentLat(e.target.value);\n if (e.nativeEvent.inputType === 'insertReplacementText' || e.nativeEvent.inputType === 'deleteContentBackward' || e.nativeEvent.inputType === 'insertText') {\n // Do not update instantly when typing\n return;\n }\n // If value is a valid number, update instantly (arrows/stepper)\n const newLat = Number(e.target.value);\n if (!isNaN(newLat)) {\n mapDispatch({ type: 'UPDATE_LOCATION', payload: { currentLocation: { ...currentLocation, lat: newLat } } });\n map?.setCenter([currentLng || 0, newLat]);\n }\n };\n const onLongitudeInputChange = (e) => {\n setCurrentLng(e.target.value);\n if (e.nativeEvent.inputType === 'insertReplacementText' || e.nativeEvent.inputType === 'deleteContentBackward' || e.nativeEvent.inputType === 'insertText') {\n return;\n }\n const newLng = Number(e.target.value);\n if (!isNaN(newLng)) {\n mapDispatch({ type: 'UPDATE_LOCATION', payload: { currentLocation: { ...currentLocation, lng: newLng } } });\n map?.setCenter([newLng, currentLat || 0]);\n }\n };\n const onZoomInputChange = (e) => {\n setCurrentZoom(e.target.value);\n if (e.nativeEvent.inputType === 'insertReplacementText' || e.nativeEvent.inputType === 'deleteContentBackward' || e.nativeEvent.inputType === 'insertText') {\n return;\n }\n const newZoom = Number(e.target.value);\n if (!isNaN(newZoom)) {\n mapDispatch({ type: 'UPDATE_LOCATION', payload: { currentLocation: { ...currentLocation, zoom: newZoom } } });\n map?.setZoom(newZoom);\n }\n };\n\n // Commit changes onBlur or Enter\n const commitLat = () => {\n const newLat = Number(currentLat);\n if (!isNaN(newLat)) {\n mapDispatch({ type: 'UPDATE_LOCATION', payload: { currentLocation: { ...currentLocation, lat: newLat } } });\n map?.setCenter([currentLng || 0, newLat]);\n }\n };\n const commitLng = () => {\n const newLng = Number(currentLng);\n if (!isNaN(newLng)) {\n mapDispatch({ type: 'UPDATE_LOCATION', payload: { currentLocation: { ...currentLocation, lng: newLng } } });\n map?.setCenter([newLng, currentLat || 0]);\n }\n };\n const commitZoom = () => {\n const newZoom = Number(currentZoom);\n if (!isNaN(newZoom)) {\n mapDispatch({ type: 'UPDATE_LOCATION', payload: { currentLocation: { ...currentLocation, zoom: newZoom } } });\n map?.setZoom(newZoom);\n }\n };\n\n // Handle Enter key for inputs\n const handleLatKeyDown = (e) => { if (e.key === 'Enter') commitLat(); };\n const handleLngKeyDown = (e) => { if (e.key === 'Enter') commitLng(); };\n const handleZoomKeyDown = (e) => { if (e.key === 'Enter') commitZoom(); };\n\n return (\n <SettingsSection icon={LR.MapPin} title={t('location')} defaultOpen={true}>\n\n {/* Latitude & Longitude Inputs in 2 columns */}\n <div className=\"flex gap-4\">\n <div className=\"flex-1 space-y-2\">\n <label className=\"text-sm font-medium\">Latitude</label>\n <Input\n type=\"number\"\n value={currentLat ?? ''}\n step={currentZoom ? currentZoom >= 10 ? 0.0001 : currentZoom >= 5 ? 0.001 : 0.01 : 0.0001}\n onChange={onLatitudeInputChange}\n onBlur={commitLat}\n onKeyDown={handleLatKeyDown}\n placeholder={t('enter') + ' latitude'}\n />\n </div>\n <div className=\"flex-1 space-y-2\">\n <label className=\"text-sm font-medium\">Longitude</label>\n <Input\n type=\"number\"\n value={currentLng ?? ''}\n step={currentZoom ? currentZoom >= 10 ? 0.0001 : currentZoom >= 5 ? 0.001 : 0.01 : 0.0001}\n onChange={onLongitudeInputChange}\n onBlur={commitLng}\n onKeyDown={handleLngKeyDown}\n placeholder={t('enter') + ' longitude'}\n />\n </div>\n </div>\n\n {/* Zoom Input */}\n <div className=\"space-y-2\">\n <label className=\"text-sm font-medium\">Zoom</label>\n <Input\n type=\"number\"\n value={currentZoom ?? ''}\n step={0.1}\n onChange={onZoomInputChange}\n onBlur={commitZoom}\n onKeyDown={handleZoomKeyDown}\n placeholder={t('enter') + ' zoom'}\n />\n </div>\n\n {/* Country Subdivision Select */}\n <div className=\"space-y-2\">\n <label className=\"text-sm font-medium\">{t('countrySubdivision')}</label>\n <Select\n value={countrySubdivision}\n onValueChange={(value) => void onCountrySubdivisionChange(value)}\n >\n <SelectTrigger>\n <SelectValue placeholder={t('selectCountrySubdivision')} />\n </SelectTrigger>\n <SelectContent>\n {Object.entries(countrySubdivisionsData ?? {}).map(([code, sub]) => (\n <SelectItem key={code} value={code}>\n {(sub as any)?.name ?? code}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n\n {/* Municipality Input with suggestions */}\n <div className=\"space-y-2 relative\">\n <label className=\"text-sm font-medium\">{t('municipality')}</label>\n <Input\n type=\"text\"\n value={municipalityInput}\n onChange={(e) => void onMunicipalityChange(e)}\n placeholder={t('enter') + ' ' + t('municipality')}\n autoComplete=\"off\"\n />\n {showSuggestions && municipalitySuggestions.length > 0 && (\n <ul className=\"absolute z-10 bg-white border rounded shadow w-full mt-1 max-h-40 overflow-auto\">\n {municipalitySuggestions.map((suggestion, idx) => (\n <li\n key={suggestion.name + idx}\n className=\"px-3 py-2 cursor-pointer hover:bg-gray-100\"\n onClick={() => onMunicipalitySuggestionSelect(suggestion)}\n >\n {suggestion.name}\n </li>\n ))}\n </ul>\n )}\n </div>\n </SettingsSection>\n )\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuPQ,SACE,KADF;AAlPR,YAAY,QAAQ;AACpB,SAAS,uBAAuB;AAChC,YAAY,WAAW;AACvB,SAAS,gBAAgB;AAEzB,SAAS,kBAAkB;AAC3B,SAAS,aAAa;AACtB,SAAS,QAAQ,eAAe,YAAY,eAAe,mBAAmB;AAC9E,SAAS,uBAAuB;AAGzB,SAAS,iBAAiB,EAAE,YAAY,GAA6B;AAExE,QAAM,CAAC,mBAAmB,oBAAoB,IAAI,SAAS,EAAE;AAC7D,QAAM,CAAC,yBAAyB,0BAA0B,IAAI,SAA4D,CAAC,CAAC;AAC5H,QAAM,CAAC,iBAAiB,kBAAkB,IAAI,SAAS,KAAK;AAE9D,QAAM,IAAI,gBAAgB,aAAa;AACvC,QAAM,EAAC,UAAU,aAAa,OAAO,SAAQ,IAAI,MAAM,WAAW,UAAU;AAC5E,QAAM,EAAE,iBAAiB,KAAK,wBAAwB,IAAI,SAAS;AACnE,QAAM,kBAAkB,eAAe,MAAM,YAAY;AAGzD,QAAM,CAAC,YAAY,aAAa,IAAI,M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OAAO;AAAA,MAKzB,CACD,GACH;AAAA,OAEJ;AAAA,KACF;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../src/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/LocationSettings.tsx"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as LR from 'lucide-react'\nimport { useTranslations } from 'next-intl'\nimport * as React from \"react\";\nimport { useState } from 'react';\n\nimport { MapContext } from '../../../../../../../../store';\nimport { Input } from '../../../../../../../ui/';\nimport { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../../../../../../../ui/Select'\nimport { SettingsSection } from '../../../../../../../ui/ViewerSidebar/SettingsSection';\nimport { searchPlace } from '../../../../../utils/geocoding';\nimport { clearFinerLabels, flyAndSyncUrl, labelsFromParams } from '../../../../../utils/urlLocation/locationParams';\nimport { DEFAULT_LEVEL_ZOOM } from '../../../../../utils/urlLocation/locationTarget';\nimport { resolveLocationTarget } from '../../../../../utils/urlLocation/resolveLocationTarget';\n\n\nexport function LocationSettings({ countryCode }: { countryCode?: string }) {\n // Municipality autocomplete state\n const [municipalityInput, setMunicipalityInput] = useState('');\n const [municipalitySuggestions, setMunicipalitySuggestions] = useState<Array<{ name: string, lat: number, lng: number }>>([]);\n const [showSuggestions, setShowSuggestions] = useState(false);\n // Translation\n const t = useTranslations('SettingsTab')\n const {dispatch: mapDispatch, state: mapState} = React.useContext(MapContext)\n const { currentLocation, map, countrySubdivisionsData } = mapState.map;\n const orgCountryCode = (countryCode || 'CA').toLowerCase()\n\n // Local input states for lat/lng/zoom\n const [currentLat, setCurrentLat] = React.useState<number>();\n const [currentLng, setCurrentLng] = React.useState<number>();\n const [currentZoom, setCurrentZoom] = React.useState<number>();\n const [countrySubdivision, setCountrySubdivision] = React.useState<string>('');\n const [municipality, setMunicipality] = React.useState<string>('');\n\n React.useEffect(() => {\n if (currentLocation) {\n setCurrentLat(currentLocation.lat);\n setCurrentLng(currentLocation.lng);\n setCurrentZoom(currentLocation.zoom);\n setCountrySubdivision(currentLocation.countrySubdivision || '');\n setMunicipality(currentLocation.municipality || '');\n }\n }, [currentLocation]);\n\n\n // Country subdivision change handler with geocoding\n const onCountrySubdivisionChange = async (value: string) => {\n // Clear municipality input and state\n setMunicipalityInput('');\n setMunicipalitySuggestions([]);\n setShowSuggestions(false);\n mapDispatch({\n type: 'UPDATE_LOCATION',\n payload: {\n currentLocation: {\n ...currentLocation,\n countrySubdivision: value,\n municipality: ''\n }\n }\n });\n\n if (!map) return;\n const params = new URLSearchParams(window.location.search);\n params.set('countrySubdivision', value);\n params.delete('municipality');\n const resolved = await resolveLocationTarget(params, { searchPlace, countryCode: orgCountryCode });\n if (resolved?.level === 'countrySubdivision') void flyAndSyncUrl(map, resolved.target, resolved.labels);\n };\n\n // Municipality change handler with geocoding\n const onMunicipalityChange = async (e: React.ChangeEvent<HTMLInputElement>) => {\n const value = e.target.value;\n setMunicipalityInput(value);\n mapDispatch({\n type: 'UPDATE_LOCATION',\n payload: {\n currentLocation: {\n ...currentLocation,\n municipality: value\n }\n }\n });\n\n // Fetch municipality suggestions\n if (value.length > 2 && countrySubdivision) {\n const response = await fetch(\n `https://nominatim.openstreetmap.org/search?` +\n `format=json&q=${encodeURIComponent(value + ', ' + countrySubdivision)}&limit=5&countrycodes=${orgCountryCode}`\n );\n const data = await response.json();\n // Only show municipality results\n const filtered = data.filter((item: any) =>\n item.type === 'municipality' || item.class === 'boundary' && item.type === 'administrative'\n ).slice(0, 3);\n setMunicipalitySuggestions(filtered.map((item: any) => ({\n name: item.display_name.split(',')[0],\n lat: parseFloat(item.lat),\n lng: parseFloat(item.lon)\n })));\n setShowSuggestions(true);\n } else {\n setMunicipalitySuggestions([]);\n setShowSuggestions(false);\n }\n };\n\n // When a suggestion is selected, update and fly\n const onMunicipalitySuggestionSelect = (suggestion: { name: string, lat: number, lng: number }) => {\n setMunicipalityInput(suggestion.name);\n mapDispatch({\n type: 'UPDATE_LOCATION',\n payload: {\n currentLocation: {\n ...currentLocation,\n municipality: suggestion.name,\n lat: suggestion.lat,\n lng: suggestion.lng\n }\n }\n });\n setShowSuggestions(false);\n if (map) {\n const labels = clearFinerLabels({ ...labelsFromParams(new URLSearchParams(window.location.search)), municipality: suggestion.name }, 'municipality');\n void flyAndSyncUrl(map, { center: [suggestion.lng, suggestion.lat], zoom: DEFAULT_LEVEL_ZOOM.municipality }, labels);\n }\n };\n\n React.useEffect(() => {\n if (!map) return;\n const handleMoveEnd = () => {\n const newCenter = map.getCenter();\n setCurrentLat(newCenter.lat);\n setCurrentLng(newCenter.lng);\n const newZoom = map.getZoom();\n setCurrentZoom(newZoom);\n };\n map.on('moveend', handleMoveEnd);\n return () => {\n map.off('moveend', handleMoveEnd);\n };\n }, [map]);\n\n // Early return if currentLocation is not yet initialized\n if (!currentLocation) {\n return null;\n }\n\n // Input change handlers (local state only)\n // If the input is changed by arrows (stepper), update instantly\n const onLatitudeInputChange = (e) => {\n setCurrentLat(e.target.value);\n if (e.nativeEvent.inputType === 'insertReplacementText' || e.nativeEvent.inputType === 'deleteContentBackward' || e.nativeEvent.inputType === 'insertText') {\n // Do not update instantly when typing\n return;\n }\n // If value is a valid number, update instantly (arrows/stepper)\n const newLat = Number(e.target.value);\n if (!isNaN(newLat)) {\n mapDispatch({ type: 'UPDATE_LOCATION', payload: { currentLocation: { ...currentLocation, lat: newLat } } });\n map?.setCenter([currentLng || 0, newLat]);\n }\n };\n const onLongitudeInputChange = (e) => {\n setCurrentLng(e.target.value);\n if (e.nativeEvent.inputType === 'insertReplacementText' || e.nativeEvent.inputType === 'deleteContentBackward' || e.nativeEvent.inputType === 'insertText') {\n return;\n }\n const newLng = Number(e.target.value);\n if (!isNaN(newLng)) {\n mapDispatch({ type: 'UPDATE_LOCATION', payload: { currentLocation: { ...currentLocation, lng: newLng } } });\n map?.setCenter([newLng, currentLat || 0]);\n }\n };\n const onZoomInputChange = (e) => {\n setCurrentZoom(e.target.value);\n if (e.nativeEvent.inputType === 'insertReplacementText' || e.nativeEvent.inputType === 'deleteContentBackward' || e.nativeEvent.inputType === 'insertText') {\n return;\n }\n const newZoom = Number(e.target.value);\n if (!isNaN(newZoom)) {\n mapDispatch({ type: 'UPDATE_LOCATION', payload: { currentLocation: { ...currentLocation, zoom: newZoom } } });\n map?.setZoom(newZoom);\n }\n };\n\n // Commit changes onBlur or Enter\n const commitLat = () => {\n const newLat = Number(currentLat);\n if (!isNaN(newLat)) {\n mapDispatch({ type: 'UPDATE_LOCATION', payload: { currentLocation: { ...currentLocation, lat: newLat } } });\n map?.setCenter([currentLng || 0, newLat]);\n }\n };\n const commitLng = () => {\n const newLng = Number(currentLng);\n if (!isNaN(newLng)) {\n mapDispatch({ type: 'UPDATE_LOCATION', payload: { currentLocation: { ...currentLocation, lng: newLng } } });\n map?.setCenter([newLng, currentLat || 0]);\n }\n };\n const commitZoom = () => {\n const newZoom = Number(currentZoom);\n if (!isNaN(newZoom)) {\n mapDispatch({ type: 'UPDATE_LOCATION', payload: { currentLocation: { ...currentLocation, zoom: newZoom } } });\n map?.setZoom(newZoom);\n }\n };\n\n // Handle Enter key for inputs\n const handleLatKeyDown = (e) => { if (e.key === 'Enter') commitLat(); };\n const handleLngKeyDown = (e) => { if (e.key === 'Enter') commitLng(); };\n const handleZoomKeyDown = (e) => { if (e.key === 'Enter') commitZoom(); };\n\n return (\n <SettingsSection icon={LR.MapPin} title={t('location')} defaultOpen={true}>\n\n {/* Latitude & Longitude Inputs in 2 columns */}\n <div className=\"flex gap-4\">\n <div className=\"flex-1 space-y-2\">\n <label className=\"text-sm font-medium\">Latitude</label>\n <Input\n type=\"number\"\n value={currentLat ?? ''}\n step={currentZoom ? currentZoom >= 10 ? 0.0001 : currentZoom >= 5 ? 0.001 : 0.01 : 0.0001}\n onChange={onLatitudeInputChange}\n onBlur={commitLat}\n onKeyDown={handleLatKeyDown}\n placeholder={t('enter') + ' latitude'}\n />\n </div>\n <div className=\"flex-1 space-y-2\">\n <label className=\"text-sm font-medium\">Longitude</label>\n <Input\n type=\"number\"\n value={currentLng ?? ''}\n step={currentZoom ? currentZoom >= 10 ? 0.0001 : currentZoom >= 5 ? 0.001 : 0.01 : 0.0001}\n onChange={onLongitudeInputChange}\n onBlur={commitLng}\n onKeyDown={handleLngKeyDown}\n placeholder={t('enter') + ' longitude'}\n />\n </div>\n </div>\n\n {/* Zoom Input */}\n <div className=\"space-y-2\">\n <label className=\"text-sm font-medium\">Zoom</label>\n <Input\n type=\"number\"\n value={currentZoom ?? ''}\n step={0.1}\n onChange={onZoomInputChange}\n onBlur={commitZoom}\n onKeyDown={handleZoomKeyDown}\n placeholder={t('enter') + ' zoom'}\n />\n </div>\n\n {/* Country Subdivision Select */}\n <div className=\"space-y-2\">\n <label className=\"text-sm font-medium\">{t('countrySubdivision')}</label>\n <Select\n value={countrySubdivision}\n onValueChange={(value) => void onCountrySubdivisionChange(value)}\n >\n <SelectTrigger>\n <SelectValue placeholder={t('selectCountrySubdivision')} />\n </SelectTrigger>\n <SelectContent>\n {Object.entries(countrySubdivisionsData ?? {}).map(([code, sub]) => (\n <SelectItem key={code} value={code}>\n {(sub as any)?.name ?? code}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n\n {/* Municipality Input with suggestions */}\n <div className=\"space-y-2 relative\">\n <label className=\"text-sm font-medium\">{t('municipality')}</label>\n <Input\n type=\"text\"\n value={municipalityInput}\n onChange={(e) => void onMunicipalityChange(e)}\n placeholder={t('enter') + ' ' + t('municipality')}\n autoComplete=\"off\"\n />\n {showSuggestions && municipalitySuggestions.length > 0 && (\n <ul className=\"absolute z-10 bg-white border rounded shadow w-full mt-1 max-h-40 overflow-auto\">\n {municipalitySuggestions.map((suggestion, idx) => (\n <li\n key={suggestion.name + idx}\n className=\"px-3 py-2 cursor-pointer hover:bg-gray-100\"\n onClick={() => onMunicipalitySuggestionSelect(suggestion)}\n >\n {suggestion.name}\n </li>\n ))}\n </ul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B;AAAA,aACD,GACH;AAAA;AAAA;AAAA,MACF;AAAA,OACF;AAAA,IAGA,qBAAC,SAAI,WAAU,sBACb;AAAA,0BAAC,WAAM,WAAU,uBAAuB,YAAE,cAAc,GAAE;AAAA,MAC1D;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL,OAAO;AAAA,UACP,UAAU,CAAC,MAAM,KAAK,qBAAqB,CAAC;AAAA,UAC5C,aAAa,EAAE,OAAO,IAAI,MAAM,EAAE,cAAc;AAAA,UAChD,cAAa;AAAA;AAAA,MACf;AAAA,MACC,mBAAmB,wBAAwB,SAAS,KACnD,oBAAC,QAAG,WAAU,mFACX,kCAAwB,IAAI,CAAC,YAAY,QACxC;AAAA,QAAC;AAAA;AAAA,UAEC,WAAU;AAAA,UACV,SAAS,MAAM,+BAA+B,UAAU;AAAA,UAEvD,qBAAW;AAAA;AAAA,QAJP,WAAW,OAAO;AAAA,MAKzB,CACD,GACH;AAAA,OAEJ;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shareMapTool.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/src/tools/shareMapTool.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"shareMapTool.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/src/tools/shareMapTool.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAY/B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAA;AAGtD,UAAU,cAAc;IACtB,IAAI,EAAE,IAAI,CAAA;CACX;AAED,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAiCjD,CAAA"}
|
|
@@ -1,11 +1,28 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
"use client";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
4
20
|
import { jsx } from "react/jsx-runtime";
|
|
5
21
|
import * as React from "react";
|
|
6
22
|
import { MapContext } from "../../../../../store";
|
|
7
23
|
import { ShareToolSubmenu } from "../../../../ui/ShareFeature";
|
|
8
24
|
import { getMunicipalityAndProvince } from "../../utils/geocoder";
|
|
25
|
+
import { cameraSnapshot, labelsFromParams, toQueryString, withLocationParams } from "../../utils/urlLocation/locationParams";
|
|
9
26
|
const ShareMapTool = ({ tool }) => {
|
|
10
27
|
const { state: mapState } = React.useContext(MapContext);
|
|
11
28
|
const { map, organizationCountry } = mapState.map;
|
|
@@ -15,20 +32,13 @@ const ShareMapTool = ({ tool }) => {
|
|
|
15
32
|
if (map == null) {
|
|
16
33
|
return origin + pathname;
|
|
17
34
|
} else {
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
zoom: map.getZoom().toFixed(3),
|
|
26
|
-
bearing: map.getBearing().toFixed(1),
|
|
27
|
-
pitch: map.getPitch().toFixed(1),
|
|
28
|
-
municipality: shareLocation.municipality,
|
|
29
|
-
countrySubdivision: shareLocation.countrySubdivision
|
|
30
|
-
});
|
|
31
|
-
const shareUrl = `${origin}${pathname}?${params.toString()}`;
|
|
35
|
+
const camera = cameraSnapshot(map);
|
|
36
|
+
const shareLocation = await getMunicipalityAndProvince(camera.lat.toFixed(7), camera.lng.toFixed(7), organizationCountry);
|
|
37
|
+
const current = new URLSearchParams(window.location.search);
|
|
38
|
+
const { country } = labelsFromParams(current);
|
|
39
|
+
const params = withLocationParams(current, camera, __spreadValues({ country }, shareLocation));
|
|
40
|
+
params.set("viewer", "map");
|
|
41
|
+
const shareUrl = `${origin}${pathname}?${toQueryString(params)}`;
|
|
32
42
|
return shareUrl;
|
|
33
43
|
}
|
|
34
44
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/src/tools/shareMapTool.tsx"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as React from \"react\";\n\n\n// Utilities\nimport { MapContext } from '../../../../../store'\n\n\n// Custom components\nimport { ShareToolSubmenu } from '../../../../ui/ShareFeature'\nimport { getMunicipalityAndProvince } from '../../utils/geocoder'\n\nimport type { Tool } from '../../../../../types/tools'\nimport type { Map } from 'maplibre-gl'\n\ninterface ShareToolProps {\n tool: Tool\n}\n\nexport const ShareMapTool: React.FC<ShareToolProps> = ({ tool }) => {\n const { state: mapState } = React.useContext(MapContext)\n const { map, organizationCountry } = mapState.map as { map: Map | null, organizationCountry?: string }\n\n const constructShareUrl = async (): Promise<string> => {\n const origin = window.location.origin\n const pathname = window.location.pathname\n\n if (map == null) {\n return origin + pathname\n }\n else {\n
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/src/tools/shareMapTool.tsx"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as React from \"react\";\n\n\n// Utilities\nimport { MapContext } from '../../../../../store'\n\n\n// Custom components\nimport { ShareToolSubmenu } from '../../../../ui/ShareFeature'\nimport { getMunicipalityAndProvince } from '../../utils/geocoder'\nimport { cameraSnapshot, labelsFromParams, toQueryString, withLocationParams } from '../../utils/urlLocation/locationParams'\n\nimport type { Tool } from '../../../../../types/tools'\nimport type { Map } from 'maplibre-gl'\n\ninterface ShareToolProps {\n tool: Tool\n}\n\nexport const ShareMapTool: React.FC<ShareToolProps> = ({ tool }) => {\n const { state: mapState } = React.useContext(MapContext)\n const { map, organizationCountry } = mapState.map as { map: Map | null, organizationCountry?: string }\n\n const constructShareUrl = async (): Promise<string> => {\n const origin = window.location.origin\n const pathname = window.location.pathname\n\n if (map == null) {\n return origin + pathname\n }\n else {\n const camera = cameraSnapshot(map)\n const shareLocation = await getMunicipalityAndProvince(camera.lat.toFixed(7), camera.lng.toFixed(7), organizationCountry)\n\n const current = new URLSearchParams(window.location.search)\n const { country } = labelsFromParams(current)\n const params = withLocationParams(current, camera, { country, ...shareLocation })\n params.set('viewer', 'map')\n\n const shareUrl = `${origin}${pathname}?${toQueryString(params)}`\n return shareUrl\n }\n }\n\n return (\n <ShareToolSubmenu\n tool={tool}\n constructShareUrl={constructShareUrl}\n translationKey=\"ShareTool\"\n dialogTitleKey=\"map\"\n />\n )\n}"],"mappings":";;;;;;;;;;;;;;;;;AAkDI;AA7CJ,YAAY,WAAW;AAIvB,SAAS,kBAAkB;AAI3B,SAAS,wBAAwB;AACjC,SAAS,kCAAkC;AAC3C,SAAS,gBAAgB,kBAAkB,eAAe,0BAA0B;AAS7E,MAAM,eAAyC,CAAC,EAAE,KAAK,MAAM;AAClE,QAAM,EAAE,OAAO,SAAS,IAAI,MAAM,WAAW,UAAU;AACvD,QAAM,EAAE,KAAK,oBAAoB,IAAI,SAAS;AAE9C,QAAM,oBAAoB,YAA6B;AACrD,UAAM,SAAS,OAAO,SAAS;AAC/B,UAAM,WAAW,OAAO,SAAS;AAEjC,QAAI,OAAO,MAAM;AACf,aAAO,SAAS;AAAA,IAClB,OACK;AACH,YAAM,SAAS,eAAe,GAAG;AACjC,YAAM,gBAAgB,MAAM,2BAA2B,OAAO,IAAI,QAAQ,CAAC,GAAG,OAAO,IAAI,QAAQ,CAAC,GAAG,mBAAmB;AAExH,YAAM,UAAU,IAAI,gBAAgB,OAAO,SAAS,MAAM;AAC1D,YAAM,EAAE,QAAQ,IAAI,iBAAiB,OAAO;AAC5C,YAAM,SAAS,mBAAmB,SAAS,QAAQ,iBAAE,WAAY,cAAe;AAChF,aAAO,IAAI,UAAU,KAAK;AAE1B,YAAM,WAAW,GAAG,MAAM,GAAG,QAAQ,IAAI,cAAc,MAAM,CAAC;AAC9D,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA,gBAAe;AAAA,MACf,gBAAe;AAAA;AAAA,EACjB;AAEJ;","names":[]}
|
|
@@ -13,6 +13,7 @@ export declare const parseLocation: (feature: Feature) => {
|
|
|
13
13
|
};
|
|
14
14
|
export declare const handleLocationSelect: (feature: Feature, map: any, type: string, options?: {
|
|
15
15
|
editing?: boolean;
|
|
16
|
+
onMoveEnd?: () => void;
|
|
16
17
|
}) => {
|
|
17
18
|
formatted_address: any;
|
|
18
19
|
coordinates: import("geojson").Position;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geocoder.d.ts","sourceRoot":"","sources":["../../../../../../src/core/components/viewers/map/utils/geocoder.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAS,MAAM,SAAS,CAAA;AAc7C,eAAO,MAAM,0BAA0B,GAAU,UAAU,MAAM,EAAE,WAAW,MAAM,EAAE,cAAc,MAAM;;;EAmBzG,CAAA;AAGD,eAAO,MAAM,gBAAgB,GAAU,OAAO,MAAM,EAAE,cAAc,MAAM;;KAYzE,CAAA;AAGD,eAAO,MAAM,aAAa,GAAI,SAAS,OAAO;;;;CAoC7C,CAAA;AAGD,eAAO,MAAM,oBAAoB,GAAI,SAAS,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,EAAE,UAAU;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"geocoder.d.ts","sourceRoot":"","sources":["../../../../../../src/core/components/viewers/map/utils/geocoder.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAS,MAAM,SAAS,CAAA;AAc7C,eAAO,MAAM,0BAA0B,GAAU,UAAU,MAAM,EAAE,WAAW,MAAM,EAAE,cAAc,MAAM;;;EAmBzG,CAAA;AAGD,eAAO,MAAM,gBAAgB,GAAU,OAAO,MAAM,EAAE,cAAc,MAAM;;KAYzE,CAAA;AAGD,eAAO,MAAM,aAAa,GAAI,SAAS,OAAO;;;;CAoC7C,CAAA;AAGD,eAAO,MAAM,oBAAoB,GAAI,SAAS,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,EAAE,UAAU;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwFrI,CAAA;AAGD,eAAO,MAAM,kBAAkB,GAAU,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,cAAc,MAAM;;GAc3F,CAAA;AAGD,eAAO,MAAM,iBAAiB,GAAI,aAAQ;;;;;;;;;;;;;;;CAgCzC,CAAA"}
|
|
@@ -65,6 +65,9 @@ const parseLocation = (feature) => {
|
|
|
65
65
|
const handleLocationSelect = (feature, map, type, options) => {
|
|
66
66
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
67
67
|
const editing = (options == null ? void 0 : options.editing) || false;
|
|
68
|
+
const listenForMoveEnd = () => {
|
|
69
|
+
if (options == null ? void 0 : options.onMoveEnd) map.once("moveend", options.onMoveEnd);
|
|
70
|
+
};
|
|
68
71
|
const markerManager = getGeocoderMarkerManager();
|
|
69
72
|
if (type === "dbBuilding") {
|
|
70
73
|
const geometry = feature.geometry;
|
|
@@ -77,6 +80,7 @@ const handleLocationSelect = (feature, map, type, options) => {
|
|
|
77
80
|
is_database_building: true
|
|
78
81
|
};
|
|
79
82
|
if (map && center2) {
|
|
83
|
+
listenForMoveEnd();
|
|
80
84
|
map.flyTo({
|
|
81
85
|
center: addressData2.coordinates,
|
|
82
86
|
zoom: 18,
|
|
@@ -121,6 +125,7 @@ const handleLocationSelect = (feature, map, type, options) => {
|
|
|
121
125
|
// How well the result matches the query
|
|
122
126
|
};
|
|
123
127
|
if (map && center) {
|
|
128
|
+
listenForMoveEnd();
|
|
124
129
|
if (feature.bbox) {
|
|
125
130
|
map.fitBounds(feature.bbox, { speed: 2 });
|
|
126
131
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/core/components/viewers/map/utils/geocoder.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { autocompleteGeocode, reverseGeocode } from './geocoding'\nimport { MarkerManager } from './MarkerManager'\n\nimport type { Feature, Point } from 'geojson'\n\n// Global marker manager instance for geocoder\nlet geocoderMarkerManager: MarkerManager | null = null\n\n// Helper function to get or create the marker manager\nconst getGeocoderMarkerManager = (): MarkerManager => {\n if (!geocoderMarkerManager) {\n geocoderMarkerManager = new MarkerManager()\n }\n return geocoderMarkerManager\n}\n\n// Convert longitude and latitude into Municipality and Country Subdivision\nexport const getMunicipalityAndProvince = async (latitude: string, longitude: string, countryCode?: string) => {\n try {\n const features = await reverseGeocode(latitude, longitude, countryCode, { size: 1, coarse: true })\n\n if (features.length > 0) {\n const properties = features[0].properties as any\n\n const municipality = properties.locality || properties.neighbourhood || properties.county || ''\n const countrySubdivision = properties.region_a || properties.region || '' // region_a gives abbreviation like \"ON\", \"BC\"\n\n return { municipality, countrySubdivision }\n }\n\n return { municipality: '', countrySubdivision: '' }\n }\n catch (error) {\n console.error('Error fetching municipality and country subdivision:', error)\n return { municipality: '', countrySubdivision: '' }\n }\n}\n\n// Fetch address suggestions from the active autocomplete provider\nexport const fetchSuggestions = async (input: string, countryCode?: string) => {\n if (!input || input.length < 3) {\n return []\n }\n\n try {\n return await autocompleteGeocode(input, countryCode, 5)\n }\n catch (error) {\n console.error('Error fetching address suggestions:', error)\n return []\n }\n}\n\n// Parse location details for better display\nexport const parseLocation = (feature: Feature) => {\n const locationName = feature.properties?.name || ''\n const fullLabel = feature.properties?.label || ''\n\n // Try to extract location details from properties\n const properties = feature.properties\n let regionDetails = ''\n\n if (properties) {\n const locality = properties.locality\n const region = properties.region // Full countrySubdivision name\n const region_a = properties.region_a // CountrySubdivision abbreviation (ON, BC, etc.)\n const country = properties.country\n const country_a = properties.country_a // Country abbreviation (CA)\n\n // Build region details similar to your original format\n if (locality && region_a && country_a) {\n regionDetails = `${locality}, ${region_a}, ${country_a}`\n }\n else if (locality && region && country) {\n regionDetails = `${locality}, ${region}, ${country}`\n }\n else {\n // Fallback: try to extract from the full label\n const parts = fullLabel.split(', ')\n if (parts.length > 1) {\n regionDetails = parts.slice(1, 3).join(', ')\n }\n }\n }\n\n return {\n name: locationName,\n region: regionDetails,\n fullLabel: fullLabel,\n }\n}\n\n// Handle suggestion selection and map movement\nexport const handleLocationSelect = (feature: Feature, map: any, type: string, options?: { editing?: boolean }) => {\n const editing = options?.editing || false\n const markerManager = getGeocoderMarkerManager()\n\n // Handle feature with is_database_building flag\n if (type === 'dbBuilding') {\n const geometry = feature.geometry as Point\n const center = geometry.coordinates\n const addressData = {\n formatted_address: feature.properties?.label || '',\n coordinates: center,\n properties: feature.properties,\n building_id: feature.properties.gid?.replace('building-', ''),\n is_database_building: true,\n }\n\n if (map && center) {\n // Add marker to the center with editing capability\n // markerManager.create(center as [number, number], map)\n\n map.flyTo({\n center: addressData.coordinates,\n zoom: 18,\n speed: 1.5,\n })\n }\n\n return addressData\n }\n\n // Calculate center coordinates\n let center\n\n // Use bbox if available (more precise for areas)\n if (feature.bbox) {\n center = [\n feature.bbox[0] + (feature.bbox[2] - feature.bbox[0]) / 2,\n feature.bbox[1] + (feature.bbox[3] - feature.bbox[1]) / 2,\n ]\n }\n // Otherwise extract coordinates based on geometry type\n else if (feature.geometry?.type === 'Point') {\n center = (feature.geometry as any).coordinates\n }\n\n const addressData = {\n formatted_address: feature.properties?.label || feature.properties?.name || '',\n coordinates: center,\n properties: feature.properties,\n address_details: {\n name: feature.properties?.name,\n label: feature.properties?.label,\n locality: feature.properties?.locality,\n neighbourhood: feature.properties?.neighbourhood,\n region: feature.properties?.region,\n region_a: feature.properties?.region_a,\n country: feature.properties?.country,\n country_a: feature.properties?.country_a,\n postalcode: feature.properties?.postalcode,\n housenumber: feature.properties?.housenumber,\n street: feature.properties?.street,\n },\n geocode_earth_id: feature.properties?.gid, // Geocode Earth's unique id\n layer: feature.properties?.layer, // Type of place (address, venue, locality, etc.)\n confidence: feature.properties?.confidence, // Geocode Earth's confidence score\n match_type: feature.properties?.match_type, // How well the result matches the query\n }\n\n if (map && center) {\n // Add marker to the center with editing capability\n // markerManager.create(center as [number, number], map, { editing })\n\n if (feature.bbox) {\n map.fitBounds(feature.bbox, { speed: 2 })\n }\n else {\n map.flyTo({\n center: addressData.coordinates,\n zoom: 14, // Might be good idea to set zoom level depending on layer / type of place\n speed: 2,\n })\n }\n }\n\n return addressData\n}\n\n// Util function to get detailed address information\nexport const getDetailedAddress = async (coordinates: [number, number], countryCode?: string) => {\n const [longitude, latitude] = coordinates\n\n try {\n // Restrict to address-layer results (the original popover used layers=address) so\n // callers get a street address rather than the nearest venue/POI. Nominatim's zoom-18\n // reverse is already building-level, so this only refines the Pelias path.\n const features = await reverseGeocode(latitude.toString(), longitude.toString(), countryCode, { size: 1, layers: 'address' })\n return features.length > 0 ? features[0] : null\n }\n catch (error) {\n console.error('Error fetching detailed address:', error)\n return null\n }\n}\n\n// Convert a building object to a GeoJSON feature format compatible with handleLocationSelect\nexport const buildingToFeature = (building) => {\n const name = building.buildingName || ''\n\n // Validate coordinates - use the correct property names\n const longitude = Number.parseFloat(building.buildingLongitude)\n const latitude = Number.parseFloat(building.buildingLatitude)\n\n if (isNaN(longitude) || isNaN(latitude)) {\n console.error('Invalid building coordinates:', {\n longitude: building.buildingLongitude,\n latitude: building.buildingLatitude,\n buildingId: building.id,\n })\n return null\n }\n\n return {\n properties: {\n name: name,\n label: `${name}, ${[building.buildingAddress, building.buildingMunicipality, building.buildingCountrySubdivision].filter(Boolean).join(', ')}`,\n address: building.buildingAddress,\n municipality: building.buildingMunicipality,\n countrySubdivision: building.buildingCountrySubdivision,\n postalCode: building.buildingPostalCode,\n gid: `building-${building.id}`,\n },\n geometry: {\n type: 'Point',\n coordinates: [longitude, latitude],\n },\n is_database_building: true,\n }\n}\n\n// // Enhanced marker creation with editing capabilities\n// export const createGeocoderMarker = (coordinates: [number, number], map: any, options?: { editing?: boolean }) => {\n// const editing = options?.editing || false\n// const markerManager = getGeocoderMarkerManager()\n// markerManager.create(coordinates, map, { editing })\n// return markerManager\n// }\n\n// Helper function to remove the current marker\n// export const removeGeocoderMarker = (): void => {\n// const markerManager = getGeocoderMarkerManager()\n// markerManager.remove()\n// }\n"],"mappings":"AAGA,SAAS,qBAAqB,sBAAsB;AACpD,SAAS,qBAAqB;AAK9B,IAAI,wBAA8C;AAGlD,MAAM,2BAA2B,MAAqB;AACpD,MAAI,CAAC,uBAAuB;AAC1B,4BAAwB,IAAI,cAAc;AAAA,EAC5C;AACA,SAAO;AACT;AAGO,MAAM,6BAA6B,OAAO,UAAkB,WAAmB,gBAAyB;AAC7G,MAAI;AACF,UAAM,WAAW,MAAM,eAAe,UAAU,WAAW,aAAa,EAAE,MAAM,GAAG,QAAQ,KAAK,CAA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;AAGO,MAAM,oBAAoB,CAAC,aAAa;AAC7C,QAAM,OAAO,SAAS,gBAAgB;AAGtC,QAAM,YAAY,OAAO,WAAW,SAAS,iBAAiB;AAC9D,QAAM,WAAW,OAAO,WAAW,SAAS,gBAAgB;AAE5D,MAAI,MAAM,SAAS,KAAK,MAAM,QAAQ,GAAG;AACvC,YAAQ,MAAM,iCAAiC;AAAA,MAC7C,WAAW,SAAS;AAAA,MACpB,UAAU,SAAS;AAAA,MACnB,YAAY,SAAS;AAAA,IACvB,CAAC;AACD,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,YAAY;AAAA,MACV;AAAA,MACA,OAAO,GAAG,IAAI,KAAK,CAAC,SAAS,iBAAiB,SAAS,sBAAsB,SAAS,0BAA0B,EAAE,OAAO,OAAO,EAAE,KAAK,IAAI,CAAC;AAAA,MAC5I,SAAS,SAAS;AAAA,MAClB,cAAc,SAAS;AAAA,MACvB,oBAAoB,SAAS;AAAA,MAC7B,YAAY,SAAS;AAAA,MACrB,KAAK,YAAY,SAAS,EAAE;AAAA,IAC9B;AAAA,IACA,UAAU;AAAA,MACR,MAAM;AAAA,MACN,aAAa,CAAC,WAAW,QAAQ;AAAA,IACnC;AAAA,IACA,sBAAsB;AAAA,EACxB;AACF;","names":["center","addressData"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/core/components/viewers/map/utils/geocoder.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { autocompleteGeocode, reverseGeocode } from './geocoding'\nimport { MarkerManager } from './MarkerManager'\n\nimport type { Feature, Point } from 'geojson'\n\n// Global marker manager instance for geocoder\nlet geocoderMarkerManager: MarkerManager | null = null\n\n// Helper function to get or create the marker manager\nconst getGeocoderMarkerManager = (): MarkerManager => {\n if (!geocoderMarkerManager) {\n geocoderMarkerManager = new MarkerManager()\n }\n return geocoderMarkerManager\n}\n\n// Convert longitude and latitude into Municipality and Country Subdivision\nexport const getMunicipalityAndProvince = async (latitude: string, longitude: string, countryCode?: string) => {\n try {\n const features = await reverseGeocode(latitude, longitude, countryCode, { size: 1, coarse: true })\n\n if (features.length > 0) {\n const properties = features[0].properties as any\n\n const municipality = properties.locality || properties.neighbourhood || properties.county || ''\n const countrySubdivision = properties.region_a || properties.region || '' // region_a gives abbreviation like \"ON\", \"BC\"\n\n return { municipality, countrySubdivision }\n }\n\n return { municipality: '', countrySubdivision: '' }\n }\n catch (error) {\n console.error('Error fetching municipality and country subdivision:', error)\n return { municipality: '', countrySubdivision: '' }\n }\n}\n\n// Fetch address suggestions from the active autocomplete provider\nexport const fetchSuggestions = async (input: string, countryCode?: string) => {\n if (!input || input.length < 3) {\n return []\n }\n\n try {\n return await autocompleteGeocode(input, countryCode, 5)\n }\n catch (error) {\n console.error('Error fetching address suggestions:', error)\n return []\n }\n}\n\n// Parse location details for better display\nexport const parseLocation = (feature: Feature) => {\n const locationName = feature.properties?.name || ''\n const fullLabel = feature.properties?.label || ''\n\n // Try to extract location details from properties\n const properties = feature.properties\n let regionDetails = ''\n\n if (properties) {\n const locality = properties.locality\n const region = properties.region // Full countrySubdivision name\n const region_a = properties.region_a // CountrySubdivision abbreviation (ON, BC, etc.)\n const country = properties.country\n const country_a = properties.country_a // Country abbreviation (CA)\n\n // Build region details similar to your original format\n if (locality && region_a && country_a) {\n regionDetails = `${locality}, ${region_a}, ${country_a}`\n }\n else if (locality && region && country) {\n regionDetails = `${locality}, ${region}, ${country}`\n }\n else {\n // Fallback: try to extract from the full label\n const parts = fullLabel.split(', ')\n if (parts.length > 1) {\n regionDetails = parts.slice(1, 3).join(', ')\n }\n }\n }\n\n return {\n name: locationName,\n region: regionDetails,\n fullLabel: fullLabel,\n }\n}\n\n// Handle suggestion selection and map movement\nexport const handleLocationSelect = (feature: Feature, map: any, type: string, options?: { editing?: boolean; onMoveEnd?: () => void }) => {\n const editing = options?.editing || false\n const listenForMoveEnd = () => { if (options?.onMoveEnd) map.once('moveend', options.onMoveEnd) }\n const markerManager = getGeocoderMarkerManager()\n\n // Handle feature with is_database_building flag\n if (type === 'dbBuilding') {\n const geometry = feature.geometry as Point\n const center = geometry.coordinates\n const addressData = {\n formatted_address: feature.properties?.label || '',\n coordinates: center,\n properties: feature.properties,\n building_id: feature.properties.gid?.replace('building-', ''),\n is_database_building: true,\n }\n\n if (map && center) {\n // Add marker to the center with editing capability\n // markerManager.create(center as [number, number], map)\n\n listenForMoveEnd()\n map.flyTo({\n center: addressData.coordinates,\n zoom: 18,\n speed: 1.5,\n })\n }\n\n return addressData\n }\n\n // Calculate center coordinates\n let center\n\n // Use bbox if available (more precise for areas)\n if (feature.bbox) {\n center = [\n feature.bbox[0] + (feature.bbox[2] - feature.bbox[0]) / 2,\n feature.bbox[1] + (feature.bbox[3] - feature.bbox[1]) / 2,\n ]\n }\n // Otherwise extract coordinates based on geometry type\n else if (feature.geometry?.type === 'Point') {\n center = (feature.geometry as any).coordinates\n }\n\n const addressData = {\n formatted_address: feature.properties?.label || feature.properties?.name || '',\n coordinates: center,\n properties: feature.properties,\n address_details: {\n name: feature.properties?.name,\n label: feature.properties?.label,\n locality: feature.properties?.locality,\n neighbourhood: feature.properties?.neighbourhood,\n region: feature.properties?.region,\n region_a: feature.properties?.region_a,\n country: feature.properties?.country,\n country_a: feature.properties?.country_a,\n postalcode: feature.properties?.postalcode,\n housenumber: feature.properties?.housenumber,\n street: feature.properties?.street,\n },\n geocode_earth_id: feature.properties?.gid, // Geocode Earth's unique id\n layer: feature.properties?.layer, // Type of place (address, venue, locality, etc.)\n confidence: feature.properties?.confidence, // Geocode Earth's confidence score\n match_type: feature.properties?.match_type, // How well the result matches the query\n }\n\n if (map && center) {\n // Add marker to the center with editing capability\n // markerManager.create(center as [number, number], map, { editing })\n\n listenForMoveEnd()\n if (feature.bbox) {\n map.fitBounds(feature.bbox, { speed: 2 })\n }\n else {\n map.flyTo({\n center: addressData.coordinates,\n zoom: 14, // Might be good idea to set zoom level depending on layer / type of place\n speed: 2,\n })\n }\n }\n\n return addressData\n}\n\n// Util function to get detailed address information\nexport const getDetailedAddress = async (coordinates: [number, number], countryCode?: string) => {\n const [longitude, latitude] = coordinates\n\n try {\n // Restrict to address-layer results (the original popover used layers=address) so\n // callers get a street address rather than the nearest venue/POI. Nominatim's zoom-18\n // reverse is already building-level, so this only refines the Pelias path.\n const features = await reverseGeocode(latitude.toString(), longitude.toString(), countryCode, { size: 1, layers: 'address' })\n return features.length > 0 ? features[0] : null\n }\n catch (error) {\n console.error('Error fetching detailed address:', error)\n return null\n }\n}\n\n// Convert a building object to a GeoJSON feature format compatible with handleLocationSelect\nexport const buildingToFeature = (building) => {\n const name = building.buildingName || ''\n\n // Validate coordinates - use the correct property names\n const longitude = Number.parseFloat(building.buildingLongitude)\n const latitude = Number.parseFloat(building.buildingLatitude)\n\n if (isNaN(longitude) || isNaN(latitude)) {\n console.error('Invalid building coordinates:', {\n longitude: building.buildingLongitude,\n latitude: building.buildingLatitude,\n buildingId: building.id,\n })\n return null\n }\n\n return {\n properties: {\n name: name,\n label: `${name}, ${[building.buildingAddress, building.buildingMunicipality, building.buildingCountrySubdivision].filter(Boolean).join(', ')}`,\n address: building.buildingAddress,\n municipality: building.buildingMunicipality,\n countrySubdivision: building.buildingCountrySubdivision,\n postalCode: building.buildingPostalCode,\n gid: `building-${building.id}`,\n },\n geometry: {\n type: 'Point',\n coordinates: [longitude, latitude],\n },\n is_database_building: true,\n }\n}\n\n// // Enhanced marker creation with editing capabilities\n// export const createGeocoderMarker = (coordinates: [number, number], map: any, options?: { editing?: boolean }) => {\n// const editing = options?.editing || false\n// const markerManager = getGeocoderMarkerManager()\n// markerManager.create(coordinates, map, { editing })\n// return markerManager\n// }\n\n// Helper function to remove the current marker\n// export const removeGeocoderMarker = (): void => {\n// const markerManager = getGeocoderMarkerManager()\n// markerManager.remove()\n// }\n"],"mappings":"AAGA,SAAS,qBAAqB,sBAAsB;AACpD,SAAS,qBAAqB;AAK9B,IAAI,wBAA8C;AA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';
|
|
2
2
|
export declare const osmCategoryToLayer: (category?: string) => string;
|
|
3
|
+
/** Full subdivision name for a Pelias-style code (`QC` → `quebec`), or '' when unknown. */
|
|
4
|
+
export declare const subdivisionName: (countryCode: string, code: string) => string;
|
|
3
5
|
export declare const normalizePhotonFeature: (feature: any) => Feature;
|
|
4
6
|
export declare const normalizeNominatimResult: (data: any) => Feature;
|
|
5
7
|
//# sourceMappingURL=adapters.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapters.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/utils/geocoding/adapters.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAGtC,eAAO,MAAM,kBAAkB,GAAI,WAAW,MAAM,KAAG,MAoBtD,CAAA;
|
|
1
|
+
{"version":3,"file":"adapters.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/utils/geocoding/adapters.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAGtC,eAAO,MAAM,kBAAkB,GAAI,WAAW,MAAM,KAAG,MAoBtD,CAAA;AAiCD,2FAA2F;AAC3F,eAAO,MAAM,eAAe,GAAI,aAAa,MAAM,EAAE,MAAM,MAAM,KAAG,MAInE,CAAA;AAGD,eAAO,MAAM,sBAAsB,GAAI,SAAS,GAAG,KAAG,OAuCrD,CAAA;AAGD,eAAO,MAAM,wBAAwB,GAAI,MAAM,GAAG,KAAG,OAkCpD,CAAA"}
|
|
@@ -122,6 +122,12 @@ const subdivisionAbbreviation = (countryCode, state) => {
|
|
|
122
122
|
const table = SUBDIVISION_ABBREVIATIONS[(countryCode || "").toUpperCase()];
|
|
123
123
|
return table && table[state.trim().toLowerCase()] || "";
|
|
124
124
|
};
|
|
125
|
+
const subdivisionName = (countryCode, code) => {
|
|
126
|
+
var _a, _b;
|
|
127
|
+
const table = (_a = SUBDIVISION_ABBREVIATIONS[(countryCode || "").toUpperCase()]) != null ? _a : {};
|
|
128
|
+
const upper = code.trim().toUpperCase();
|
|
129
|
+
return (_b = Object.keys(table).find((name) => table[name] === upper)) != null ? _b : "";
|
|
130
|
+
};
|
|
125
131
|
const normalizePhotonFeature = (feature) => {
|
|
126
132
|
const p = feature.properties || {};
|
|
127
133
|
const region = p.state || "";
|
|
@@ -187,6 +193,7 @@ const normalizeNominatimResult = (data) => {
|
|
|
187
193
|
export {
|
|
188
194
|
normalizeNominatimResult,
|
|
189
195
|
normalizePhotonFeature,
|
|
190
|
-
osmCategoryToLayer
|
|
196
|
+
osmCategoryToLayer,
|
|
197
|
+
subdivisionName
|
|
191
198
|
};
|
|
192
199
|
//# sourceMappingURL=adapters.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/utils/geocoding/adapters.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport type { Feature } from 'geojson'\n\n// Map OSM place categories onto Pelias-style layer names (best effort, display-only).\nexport const osmCategoryToLayer = (category?: string): string => {\n switch (category) {\n case 'house':\n case 'building': return 'address'\n case 'street':\n case 'road': return 'street'\n case 'city':\n case 'town':\n case 'village':\n case 'hamlet':\n case 'locality': return 'locality'\n case 'district':\n case 'suburb':\n case 'neighbourhood': return 'neighbourhood'\n case 'county': return 'county'\n case 'state':\n case 'region': return 'region'\n case 'country': return 'country'\n default: return category || 'venue'\n }\n}\n\n// Photon (OSM) returns full subdivision names (\"Ontario\"); the rest of the app expects\n// Pelias-style abbreviations (\"ON\"). Map common North American ones so the public\n// fallback populates region_a the way Geocode Earth / Pelias do.\nconst SUBDIVISION_ABBREVIATIONS: Record<string, Record<string, string>> = {\n CA: {\n 'alberta': 'AB', 'british columbia': 'BC', 'manitoba': 'MB', 'new brunswick': 'NB',\n 'newfoundland and labrador': 'NL', 'northwest territories': 'NT', 'nova scotia': 'NS',\n 'nunavut': 'NU', 'ontario': 'ON', 'prince edward island': 'PE', 'quebec': 'QC',\n 'québec': 'QC', 'saskatchewan': 'SK', 'yukon': 'YT',\n },\n US: {\n 'alabama': 'AL', 'alaska': 'AK', 'arizona': 'AZ', 'arkansas': 'AR', 'california': 'CA',\n 'colorado': 'CO', 'connecticut': 'CT', 'delaware': 'DE', 'district of columbia': 'DC',\n 'florida': 'FL', 'georgia': 'GA', 'hawaii': 'HI', 'idaho': 'ID', 'illinois': 'IL',\n 'indiana': 'IN', 'iowa': 'IA', 'kansas': 'KS', 'kentucky': 'KY', 'louisiana': 'LA',\n 'maine': 'ME', 'maryland': 'MD', 'massachusetts': 'MA', 'michigan': 'MI', 'minnesota': 'MN',\n 'mississippi': 'MS', 'missouri': 'MO', 'montana': 'MT', 'nebraska': 'NE', 'nevada': 'NV',\n 'new hampshire': 'NH', 'new jersey': 'NJ', 'new mexico': 'NM', 'new york': 'NY',\n 'north carolina': 'NC', 'north dakota': 'ND', 'ohio': 'OH', 'oklahoma': 'OK', 'oregon': 'OR',\n 'pennsylvania': 'PA', 'rhode island': 'RI', 'south carolina': 'SC', 'south dakota': 'SD',\n 'tennessee': 'TN', 'texas': 'TX', 'utah': 'UT', 'vermont': 'VT', 'virginia': 'VA',\n 'washington': 'WA', 'west virginia': 'WV', 'wisconsin': 'WI', 'wyoming': 'WY',\n },\n}\n\nconst subdivisionAbbreviation = (countryCode: string, state?: string): string => {\n if (!state) return ''\n const table = SUBDIVISION_ABBREVIATIONS[(countryCode || '').toUpperCase()]\n return (table && table[state.trim().toLowerCase()]) || ''\n}\n\n// Normalize a Photon autocomplete feature into the Pelias feature shape.\nexport const normalizePhotonFeature = (feature: any): Feature => {\n const p = feature.properties || {}\n const region = p.state || ''\n const country = p.country || ''\n const country_a = (p.countrycode || '').toUpperCase()\n const region_a = subdivisionAbbreviation(country_a, region)\n const locality = p.city || p.town || p.village || p.district || ''\n const name = p.name || [p.housenumber, p.street].filter(Boolean).join(' ') || locality\n // Match the Pelias label shape (\"Name, City, ON, Country\") so label-parsing consumers work.\n const label = [name, locality && locality !== name ? locality : null, region_a || region, country]\n .filter(Boolean)\n .join(', ')\n\n // Photon `extent` is [west, north, east, south]; Pelias bbox is [west, south, east, north].\n const bbox: [number, number, number, number] | undefined = Array.isArray(p.extent) && p.extent.length === 4\n ? [p.extent[0], p.extent[3], p.extent[2], p.extent[1]]\n : undefined\n\n return {\n type: 'Feature',\n geometry: feature.geometry,\n ...(bbox ? { bbox } : {}),\n properties: {\n name,\n label,\n housenumber: p.housenumber,\n street: p.street,\n locality,\n neighbourhood: p.district,\n county: p.county,\n region,\n region_a, // mapped from the full subdivision name where known (SUBDIVISION_ABBREVIATIONS)\n country,\n country_a,\n postalcode: p.postcode,\n gid: p.osm_id != null ? `osm:${p.osm_type}:${p.osm_id}` : undefined,\n layer: osmCategoryToLayer(p.type),\n },\n } as Feature\n}\n\n// Normalize a Nominatim reverse result into the Pelias feature shape.\nexport const normalizeNominatimResult = (data: any): Feature => {\n const a = data.address || {}\n // ISO3166-2-lvl4 looks like \"CA-ON\"; the suffix is the Pelias region_a abbreviation.\n const region_a = (a['ISO3166-2-lvl4'] || '').split('-')[1] || ''\n const locality = a.city || a.town || a.village || a.municipality || a.suburb || a.neighbourhood || a.county || ''\n const name = a.road ? [a.house_number, a.road].filter(Boolean).join(' ') : (locality || (data.display_name || '').split(',')[0])\n\n // Nominatim boundingbox is [minlat, maxlat, minlon, maxlon]; Pelias bbox is [west, south, east, north].\n const bb = data.boundingbox\n const bbox: [number, number, number, number] | undefined = Array.isArray(bb) && bb.length === 4\n ? [Number(bb[2]), Number(bb[0]), Number(bb[3]), Number(bb[1])]\n : undefined\n\n return {\n type: 'Feature',\n geometry: { type: 'Point', coordinates: [Number(data.lon), Number(data.lat)] },\n ...(bbox ? { bbox } : {}),\n properties: {\n name,\n label: data.display_name || '',\n housenumber: a.house_number,\n street: a.road,\n locality,\n neighbourhood: a.neighbourhood || a.suburb,\n county: a.county,\n region: a.state,\n region_a,\n country: a.country,\n country_a: (a.country_code || '').toUpperCase(),\n postalcode: a.postcode,\n gid: data.osm_id != null ? `osm:${data.osm_type}:${data.osm_id}` : undefined,\n layer: osmCategoryToLayer(data.addresstype || data.type),\n },\n } as Feature\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAMO,MAAM,qBAAqB,CAAC,aAA8B;AAC/D,UAAQ,UAAU;AAAA,IAChB,KAAK;AAAA,IACL,KAAK;AAAY,aAAO;AAAA,IACxB,KAAK;AAAA,IACL,KAAK;AAAQ,aAAO;AAAA,IACpB,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAY,aAAO;AAAA,IACxB,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAiB,aAAO;AAAA,IAC7B,KAAK;AAAU,aAAO;AAAA,IACtB,KAAK;AAAA,IACL,KAAK;AAAU,aAAO;AAAA,IACtB,KAAK;AAAW,aAAO;AAAA,IACvB;AAAS,aAAO,YAAY;AAAA,EAC9B;AACF;AAKA,MAAM,4BAAoE;AAAA,EACxE,IAAI;AAAA,IACF,WAAW;AAAA,IAAM,oBAAoB;AAAA,IAAM,YAAY;AAAA,IAAM,iBAAiB;AAAA,IAC9E,6BAA6B;AAAA,IAAM,yBAAyB;AAAA,IAAM,eAAe;AAAA,IACjF,WAAW;AAAA,IAAM,WAAW;AAAA,IAAM,wBAAwB;AAAA,IAAM,UAAU;AAAA,IAC1E,aAAU;AAAA,IAAM,gBAAgB;AAAA,IAAM,SAAS;AAAA,EACjD;AAAA,EACA,IAAI;AAAA,IACF,WAAW;AAAA,IAAM,UAAU;AAAA,IAAM,WAAW;AAAA,IAAM,YAAY;AAAA,IAAM,cAAc;AAAA,IAClF,YAAY;AAAA,IAAM,eAAe;AAAA,IAAM,YAAY;AAAA,IAAM,wBAAwB;AAAA,IACjF,WAAW;AAAA,IAAM,WAAW;AAAA,IAAM,UAAU;AAA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AAK,gBAAgB,IAAI,MAAM,GAAG,EAAE,CAAC;AAG9H,QAAM,KAAK,KAAK;AAChB,QAAM,OAAqD,MAAM,QAAQ,EAAE,KAAK,GAAG,WAAW,IAC1F,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,OAAO,GAAG,CAAC,CAAC,GAAG,OAAO,GAAG,CAAC,CAAC,GAAG,OAAO,GAAG,CAAC,CAAC,CAAC,IAC3D;AAEJ,SAAO;AAAA,IACL,MAAM;AAAA,IACN,UAAU,EAAE,MAAM,SAAS,aAAa,CAAC,OAAO,KAAK,GAAG,GAAG,OAAO,KAAK,GAAG,CAAC,EAAE;AAAA,KACzE,OAAO,EAAE,KAAK,IAAI,CAAC,IAHlB;AAAA,IAIL,YAAY;AAAA,MACV;AAAA,MACA,OAAO,KAAK,gBAAgB;AAAA,MAC5B,aAAa,EAAE;AAAA,MACf,QAAQ,EAAE;AAAA,MACV;AAAA,MACA,eAAe,EAAE,iBAAiB,EAAE;AAAA,MACpC,QAAQ,EAAE;AAAA,MACV,QAAQ,EAAE;AAAA,MACV;AAAA,MACA,SAAS,EAAE;AAAA,MACX,YAAY,EAAE,gBAAgB,IAAI,YAAY;AAAA,MAC9C,YAAY,EAAE;AAAA,MACd,KAAK,KAAK,UAAU,OAAO,OAAO,KAAK,QAAQ,IAAI,KAAK,MAAM,KAAK;AAAA,MACnE,OAAO,mBAAmB,KAAK,eAAe,KAAK,IAAI;AAAA,IACzD;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/utils/geocoding/adapters.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport type { Feature } from 'geojson'\n\n// Map OSM place categories onto Pelias-style layer names (best effort, display-only).\nexport const osmCategoryToLayer = (category?: string): string => {\n switch (category) {\n case 'house':\n case 'building': return 'address'\n case 'street':\n case 'road': return 'street'\n case 'city':\n case 'town':\n case 'village':\n case 'hamlet':\n case 'locality': return 'locality'\n case 'district':\n case 'suburb':\n case 'neighbourhood': return 'neighbourhood'\n case 'county': return 'county'\n case 'state':\n case 'region': return 'region'\n case 'country': return 'country'\n default: return category || 'venue'\n }\n}\n\n// Photon (OSM) returns full subdivision names (\"Ontario\"); the rest of the app expects\n// Pelias-style abbreviations (\"ON\"). Map common North American ones so the public\n// fallback populates region_a the way Geocode Earth / Pelias do.\nconst SUBDIVISION_ABBREVIATIONS: Record<string, Record<string, string>> = {\n CA: {\n 'alberta': 'AB', 'british columbia': 'BC', 'manitoba': 'MB', 'new brunswick': 'NB',\n 'newfoundland and labrador': 'NL', 'northwest territories': 'NT', 'nova scotia': 'NS',\n 'nunavut': 'NU', 'ontario': 'ON', 'prince edward island': 'PE', 'quebec': 'QC',\n 'québec': 'QC', 'saskatchewan': 'SK', 'yukon': 'YT',\n },\n US: {\n 'alabama': 'AL', 'alaska': 'AK', 'arizona': 'AZ', 'arkansas': 'AR', 'california': 'CA',\n 'colorado': 'CO', 'connecticut': 'CT', 'delaware': 'DE', 'district of columbia': 'DC',\n 'florida': 'FL', 'georgia': 'GA', 'hawaii': 'HI', 'idaho': 'ID', 'illinois': 'IL',\n 'indiana': 'IN', 'iowa': 'IA', 'kansas': 'KS', 'kentucky': 'KY', 'louisiana': 'LA',\n 'maine': 'ME', 'maryland': 'MD', 'massachusetts': 'MA', 'michigan': 'MI', 'minnesota': 'MN',\n 'mississippi': 'MS', 'missouri': 'MO', 'montana': 'MT', 'nebraska': 'NE', 'nevada': 'NV',\n 'new hampshire': 'NH', 'new jersey': 'NJ', 'new mexico': 'NM', 'new york': 'NY',\n 'north carolina': 'NC', 'north dakota': 'ND', 'ohio': 'OH', 'oklahoma': 'OK', 'oregon': 'OR',\n 'pennsylvania': 'PA', 'rhode island': 'RI', 'south carolina': 'SC', 'south dakota': 'SD',\n 'tennessee': 'TN', 'texas': 'TX', 'utah': 'UT', 'vermont': 'VT', 'virginia': 'VA',\n 'washington': 'WA', 'west virginia': 'WV', 'wisconsin': 'WI', 'wyoming': 'WY',\n },\n}\n\nconst subdivisionAbbreviation = (countryCode: string, state?: string): string => {\n if (!state) return ''\n const table = SUBDIVISION_ABBREVIATIONS[(countryCode || '').toUpperCase()]\n return (table && table[state.trim().toLowerCase()]) || ''\n}\n\n/** Full subdivision name for a Pelias-style code (`QC` → `quebec`), or '' when unknown. */\nexport const subdivisionName = (countryCode: string, code: string): string => {\n const table = SUBDIVISION_ABBREVIATIONS[(countryCode || '').toUpperCase()] ?? {}\n const upper = code.trim().toUpperCase()\n return Object.keys(table).find(name => table[name] === upper) ?? ''\n}\n\n// Normalize a Photon autocomplete feature into the Pelias feature shape.\nexport const normalizePhotonFeature = (feature: any): Feature => {\n const p = feature.properties || {}\n const region = p.state || ''\n const country = p.country || ''\n const country_a = (p.countrycode || '').toUpperCase()\n const region_a = subdivisionAbbreviation(country_a, region)\n const locality = p.city || p.town || p.village || p.district || ''\n const name = p.name || [p.housenumber, p.street].filter(Boolean).join(' ') || locality\n // Match the Pelias label shape (\"Name, City, ON, Country\") so label-parsing consumers work.\n const label = [name, locality && locality !== name ? locality : null, region_a || region, country]\n .filter(Boolean)\n .join(', ')\n\n // Photon `extent` is [west, north, east, south]; Pelias bbox is [west, south, east, north].\n const bbox: [number, number, number, number] | undefined = Array.isArray(p.extent) && p.extent.length === 4\n ? [p.extent[0], p.extent[3], p.extent[2], p.extent[1]]\n : undefined\n\n return {\n type: 'Feature',\n geometry: feature.geometry,\n ...(bbox ? { bbox } : {}),\n properties: {\n name,\n label,\n housenumber: p.housenumber,\n street: p.street,\n locality,\n neighbourhood: p.district,\n county: p.county,\n region,\n region_a, // mapped from the full subdivision name where known (SUBDIVISION_ABBREVIATIONS)\n country,\n country_a,\n postalcode: p.postcode,\n gid: p.osm_id != null ? `osm:${p.osm_type}:${p.osm_id}` : undefined,\n layer: osmCategoryToLayer(p.type),\n },\n } as Feature\n}\n\n// Normalize a Nominatim reverse result into the Pelias feature shape.\nexport const normalizeNominatimResult = (data: any): Feature => {\n const a = data.address || {}\n // ISO3166-2-lvl4 looks like \"CA-ON\"; the suffix is the Pelias region_a abbreviation.\n const region_a = (a['ISO3166-2-lvl4'] || '').split('-')[1] || ''\n const locality = a.city || a.town || a.village || a.municipality || a.suburb || a.neighbourhood || a.county || ''\n const name = a.road ? [a.house_number, a.road].filter(Boolean).join(' ') : (locality || (data.display_name || '').split(',')[0])\n\n // Nominatim boundingbox is [minlat, maxlat, minlon, maxlon]; Pelias bbox is [west, south, east, north].\n const bb = data.boundingbox\n const bbox: [number, number, number, number] | undefined = Array.isArray(bb) && bb.length === 4\n ? [Number(bb[2]), Number(bb[0]), Number(bb[3]), Number(bb[1])]\n : undefined\n\n return {\n type: 'Feature',\n geometry: { type: 'Point', coordinates: [Number(data.lon), Number(data.lat)] },\n ...(bbox ? { bbox } : {}),\n properties: {\n name,\n label: data.display_name || '',\n housenumber: a.house_number,\n street: a.road,\n locality,\n neighbourhood: a.neighbourhood || a.suburb,\n county: a.county,\n region: a.state,\n region_a,\n country: a.country,\n country_a: (a.country_code || '').toUpperCase(),\n postalcode: a.postcode,\n gid: data.osm_id != null ? `osm:${data.osm_type}:${data.osm_id}` : undefined,\n layer: osmCategoryToLayer(data.addresstype || data.type),\n },\n } as Feature\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAMO,MAAM,qBAAqB,CAAC,aAA8B;AAC/D,UAAQ,UAAU;AAAA,IAChB,KAAK;AAAA,IACL,KAAK;AAAY,aAAO;AAAA,IACxB,KAAK;AAAA,IACL,KAAK;AAAQ,aAAO;AAAA,IACpB,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAY,aAAO;AAAA,IACxB,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAiB,aAAO;AAAA,IAC7B,KAAK;AAAU,aAAO;AAAA,IACtB,KAAK;AAAA,IACL,KAAK;AAAU,aAAO;AAAA,IACtB,K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AAK,GAAG,GAAG,OAAO,KAAK,GAAG,CAAC,EAAE;AAAA,KACzE,OAAO,EAAE,KAAK,IAAI,CAAC,IAHlB;AAAA,IAIL,YAAY;AAAA,MACV;AAAA,MACA,OAAO,KAAK,gBAAgB;AAAA,MAC5B,aAAa,EAAE;AAAA,MACf,QAAQ,EAAE;AAAA,MACV;AAAA,MACA,eAAe,EAAE,iBAAiB,EAAE;AAAA,MACpC,QAAQ,EAAE;AAAA,MACV,QAAQ,EAAE;AAAA,MACV;AAAA,MACA,SAAS,EAAE;AAAA,MACX,YAAY,EAAE,gBAAgB,IAAI,YAAY;AAAA,MAC9C,YAAY,EAAE;AAAA,MACd,KAAK,KAAK,UAAU,OAAO,OAAO,KAAK,QAAQ,IAAI,KAAK,MAAM,KAAK;AAAA,MACnE,OAAO,mBAAmB,KAAK,eAAe,KAAK,IAAI;AAAA,IACzD;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PlaceContext, PlaceLevel } from './placeSearch';
|
|
1
2
|
import type { Feature } from 'geojson';
|
|
2
3
|
export declare const autocompleteGeocode: (text: string, countryCode: string, size: number) => Promise<Feature[]>;
|
|
3
4
|
export declare const reverseGeocode: (latitude: string, longitude: string, countryCode: string, { size, coarse, layers }?: {
|
|
@@ -5,4 +6,6 @@ export declare const reverseGeocode: (latitude: string, longitude: string, count
|
|
|
5
6
|
coarse?: boolean;
|
|
6
7
|
layers?: string;
|
|
7
8
|
}) => Promise<Feature[]>;
|
|
9
|
+
/** First result in `level`'s category that lies inside the parent subdivision, or null to go up a level. */
|
|
10
|
+
export declare const searchPlace: (level: PlaceLevel, name: string, context?: PlaceContext) => Promise<Feature | null>;
|
|
8
11
|
//# sourceMappingURL=index.d.ts.map
|