@open-pioneer/map 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/layers/AbstractLayer.d.ts +36 -0
- package/layers/AbstractLayer.js +119 -1
- package/layers/AbstractLayer.js.map +1 -1
- package/layers/WMSLayer.js +4 -2
- package/layers/WMSLayer.js.map +1 -1
- package/layers/WMTSLayer.js +1 -1
- package/layers/WMTSLayer.js.map +1 -1
- package/layers/shared/LayerConfig.d.ts +16 -0
- package/layers/wms/WMSSublayer.js.map +1 -1
- package/model/Highlights.js.map +1 -1
- package/model/LayerCollection.js +3 -0
- package/model/LayerCollection.js.map +1 -1
- package/model/MapModel.js +1 -1
- package/model/MapModel.js.map +1 -1
- package/model/createMapModel.js.map +1 -1
- package/package.json +10 -10
- package/ui/MapContainer.js.map +1 -1
- package/ui/hooks/useMapModel.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMapModel.js","sources":["useMapModel.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { useService } from \"open-pioneer:react-hooks\";\nimport { useMemo } from \"react\";\nimport { useAsync } from \"react-use\";\nimport { MapRegistry } from \"../../MapRegistry\";\nimport { MapModel } from \"../../model/MapModel\";\nimport { useDefaultMap } from \"../DefaultMapProvider\";\n\n/**\n * Return value of {@link useMapModel}.\n *\n * @group UI Components and Hooks\n **/\nexport type UseMapModelResult = UseMapModelLoading | UseMapModelResolved | UseMapModelRejected;\n\n/** @group UI Components and Hooks */\nexport interface UseMapModelLoading {\n kind: \"loading\";\n map?: undefined;\n error?: undefined;\n}\n\n/** @group UI Components and Hooks */\nexport interface UseMapModelResolved {\n kind: \"resolved\";\n map: MapModel;\n error?: undefined;\n}\n\n/** @group UI Components and Hooks */\nexport interface UseMapModelRejected {\n kind: \"rejected\";\n map?: undefined;\n error: Error;\n}\n\n/**\n * React hook that returns the default map model (if available, see {@link DefaultMapProvider}).\n *\n * @deprecated Use {@link useMapModelValue} instead.\n *\n * @group UI Components and Hooks\n */\nexport function useMapModel(): UseMapModelResult;\n\n/**\n * React hook that looks up the map with the given id in the `map.MapRegistry` service.\n *\n * Returns an object representing the progress, which will eventually represent either\n * the map model value or an initialization error.\n *\n * The map model cannot be returned directly because it may not have completed its initialization yet.\n *\n * @group UI Components and Hooks\n */\nexport function useMapModel(mapId: string): UseMapModelResult;\n\n/**\n * React hook that resolves a map model specified by the given `props`.\n *\n * Returns an object representing the progress, which will eventually represent either\n * the map model value or an initialization error.\n *\n * The map model cannot be returned directly because it may not have completed its initialization yet.\n *\n * @group UI Components and Hooks\n */\nexport function useMapModel(props: { mapId: string }): UseMapModelResult;\n\nexport function useMapModel(props?: undefined | string | { mapId: string }): UseMapModelResult {\n if (props instanceof MapModel) {\n // This cannot happen in valid typescript code, but it might be a common mistake.\n throw new Error(\n `Map model instances cannot be passed directly to 'useMapModel' (see TypeScript signature).`\n );\n }\n\n const defaultMap = useDefaultMap();\n const mapRegistry = useService<MapRegistry>(\"map.MapRegistry\");\n\n let mapId: string | undefined;\n if (typeof props === \"string\") {\n mapId = props;\n } else if (typeof props === \"object\") {\n mapId = props.mapId;\n }\n\n if (mapId == null && !defaultMap) {\n throw new Error(\n \"No map specified. Either configure a mapId or use the DefaultMapProvider.\"\n );\n }\n\n const state = useAsync(async () => {\n if (mapId == null) {\n // For backwards compatibility\n return defaultMap
|
|
1
|
+
{"version":3,"file":"useMapModel.js","sources":["useMapModel.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { useService } from \"open-pioneer:react-hooks\";\nimport { useMemo } from \"react\";\nimport { useAsync } from \"react-use\";\nimport { MapRegistry } from \"../../MapRegistry\";\nimport { MapModel } from \"../../model/MapModel\";\nimport { useDefaultMap } from \"../DefaultMapProvider\";\n\n/**\n * Return value of {@link useMapModel}.\n *\n * @group UI Components and Hooks\n **/\nexport type UseMapModelResult = UseMapModelLoading | UseMapModelResolved | UseMapModelRejected;\n\n/** @group UI Components and Hooks */\nexport interface UseMapModelLoading {\n kind: \"loading\";\n map?: undefined;\n error?: undefined;\n}\n\n/** @group UI Components and Hooks */\nexport interface UseMapModelResolved {\n kind: \"resolved\";\n map: MapModel;\n error?: undefined;\n}\n\n/** @group UI Components and Hooks */\nexport interface UseMapModelRejected {\n kind: \"rejected\";\n map?: undefined;\n error: Error;\n}\n\n/**\n * React hook that returns the default map model (if available, see {@link DefaultMapProvider}).\n *\n * @deprecated Use {@link useMapModelValue} instead.\n *\n * @group UI Components and Hooks\n */\nexport function useMapModel(): UseMapModelResult;\n\n/**\n * React hook that looks up the map with the given id in the `map.MapRegistry` service.\n *\n * Returns an object representing the progress, which will eventually represent either\n * the map model value or an initialization error.\n *\n * The map model cannot be returned directly because it may not have completed its initialization yet.\n *\n * @group UI Components and Hooks\n */\nexport function useMapModel(mapId: string): UseMapModelResult;\n\n/**\n * React hook that resolves a map model specified by the given `props`.\n *\n * Returns an object representing the progress, which will eventually represent either\n * the map model value or an initialization error.\n *\n * The map model cannot be returned directly because it may not have completed its initialization yet.\n *\n * @group UI Components and Hooks\n */\nexport function useMapModel(props: { mapId: string }): UseMapModelResult;\n\nexport function useMapModel(props?: undefined | string | { mapId: string }): UseMapModelResult {\n if (props instanceof MapModel) {\n // This cannot happen in valid typescript code, but it might be a common mistake.\n throw new Error(\n `Map model instances cannot be passed directly to 'useMapModel' (see TypeScript signature).`\n );\n }\n\n const defaultMap = useDefaultMap();\n const mapRegistry = useService<MapRegistry>(\"map.MapRegistry\");\n\n let mapId: string | undefined;\n if (typeof props === \"string\") {\n mapId = props;\n } else if (typeof props === \"object\") {\n mapId = props.mapId;\n }\n\n if (mapId == null && !defaultMap) {\n throw new Error(\n \"No map specified. Either configure a mapId or use the DefaultMapProvider.\"\n );\n }\n\n const state = useAsync(async () => {\n if (mapId == null) {\n // For backwards compatibility\n return defaultMap;\n }\n\n return await mapRegistry.expectMapModel(mapId);\n }, [mapRegistry, mapId]);\n\n const result = useMemo((): UseMapModelResult => {\n if (state.loading) {\n return { kind: \"loading\" };\n }\n if (state.error) {\n return { kind: \"rejected\", error: state.error };\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return { kind: \"resolved\", map: state.value! };\n }, [state]);\n return result;\n}\n\n/**\n * Options that specify which map to use. See {@link useMapModelValue}.\n *\n * When not setting any of these properties on a component, the default map (from the `DefaultMapProvider`) will be used.\n * If that is not available either, an error will be thrown.\n *\n * @see {@link DefaultMapProvider}\n *\n * @group UI Components and Hooks\n */\nexport interface MapModelProps {\n /**\n * The map model to use.\n */\n map?: MapModel | undefined;\n}\n\n/**\n * Returns the configured map model.\n *\n * The map model is either directly configured or specified via a {@link DefaultMapProvider}.\n * If neither has been specified, an error will be thrown.\n *\n * This hook is preferable to {@link useMapModel} because it can return the map model directly, without waiting.\n *\n * @group UI Components and Hooks\n */\nexport function useMapModelValue(props?: MapModelProps): MapModel {\n if (props instanceof MapModel) {\n // This cannot happen in valid typescript code, but it might be a common mistake.\n throw new Error(\n `Map model instances cannot be passed directly to 'useMapModelValue' (see TypeScript signature).`\n );\n }\n\n const localMap = props?.map;\n const defaultMap = useDefaultMap();\n const map = localMap ?? defaultMap;\n if (!map) {\n throw new Error(\n `No map specified. ` +\n `You must either specify the map via a DefaultMapProvider parent or configure it explicitly.`\n );\n }\n return map;\n}\n"],"names":[],"mappings":";;;;;;AAsEO,SAAS,YAAY,KAAA,EAAmE;AAC3F,EAAA,IAAI,iBAAiB,QAAA,EAAU;AAE3B,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,CAAA,0FAAA;AAAA,KACJ;AAAA,EACJ;AAEA,EAAA,MAAM,aAAa,aAAA,EAAc;AACjC,EAAA,MAAM,WAAA,GAAc,WAAwB,iBAAiB,CAAA;AAE7D,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