diff --git a/.eslintrc.json b/.eslintrc.json index 47dc6d5..3be94e5 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -28,5 +28,5 @@ "rules": { "@typescript-eslint/no-explicit-any": 1 }, - "ignorePatterns": ["**/*.test.ts", "apps"] + "ignorePatterns": ["**/*.test.ts", "apps", "**/mocks"] } diff --git a/.github/workflows/qa.yml b/.github/workflows/qa.yml new file mode 100644 index 0000000..ccc9e6d --- /dev/null +++ b/.github/workflows/qa.yml @@ -0,0 +1,36 @@ +name: Quality Assurance +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, ready_for_review] + +jobs: + format-typecheck-test: + name: Formatting, types and tests + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Node & NPM + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + + - name: Install lib dependencies + run: npm ci + + - name: Formatting + run: npm run format:check + + - name: Type check + run: npm run typecheck + + - name: Linting + run: npm run lint + + - name: Run tests + run: npm test diff --git a/.gitignore b/.gitignore index 855618b..79ab79a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules/ **/.vitepress/cache +**/.vitepress/dist packages/*/dist -.idea \ No newline at end of file +.idea diff --git a/apps/examples/src/App.vue b/apps/examples/src/App.vue index 4d00764..b1591b2 100644 --- a/apps/examples/src/App.vue +++ b/apps/examples/src/App.vue @@ -8,6 +8,8 @@ import ExampleGeocoding from '@/examples/Example-Geocoding.vue' import ExampleGeocodingRaw from '@/examples/Example-Geocoding.vue?raw' import ExampleZoomToLayer from '@/examples/Example-ZoomToLayer.vue' import ExampleZoomToLayerRaw from '@/examples/Example-ZoomToLayer.vue?raw' +import ExampleMapEvents from '@/examples/Example-MapEvents.vue' +import ExampleMapEventsRaw from '@/examples/Example-MapEvents.vue?raw' import { onMounted } from 'vue' import hljs from 'highlight.js' @@ -42,8 +44,15 @@ onMounted(() => { + + + diff --git a/apps/examples/src/components/Panel.vue b/apps/examples/src/components/Panel.vue new file mode 100644 index 0000000..2fc1112 --- /dev/null +++ b/apps/examples/src/components/Panel.vue @@ -0,0 +1,9 @@ + + + + + diff --git a/apps/examples/src/examples/Example-MapEvents.vue b/apps/examples/src/examples/Example-MapEvents.vue new file mode 100644 index 0000000..ba311e1 --- /dev/null +++ b/apps/examples/src/examples/Example-MapEvents.vue @@ -0,0 +1,56 @@ + + + diff --git a/docs/api/core/functions/computeMapContextDiff.md b/docs/api/core/functions/computeMapContextDiff.md index 2f968bd..a2a5bc3 100644 --- a/docs/api/core/functions/computeMapContextDiff.md +++ b/docs/api/core/functions/computeMapContextDiff.md @@ -10,10 +10,12 @@ The following logic is produced by identifying layers in both context and determining whether they have been added, removed, changed or reordered. Identifying layers to determine if they have been added/removed/reordered is done like so: + 1. For layers with an `id` property, use non-strict equality on it (e.g. '2' and 2 are equivalent); 2. For layers without `id`, compute a hash of their base properties _excluding the `extras` property_ Determining whether layers have changed is done like so: + 1. For layers with an `id` property, the value of the `version` field is compared; if values are different (using non-strict equality), then the layer is considered to have changed; otherwise it is considered to have remained the same @@ -35,6 +37,6 @@ Determining whether layers have changed is done like so: [packages/core/lib/utils/map-context-diff.ts:72](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/utils/map-context-diff.ts#L72) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/core/functions/deepFreeze.md b/docs/api/core/functions/deepFreeze.md index 2cea43f..e319777 100644 --- a/docs/api/core/functions/deepFreeze.md +++ b/docs/api/core/functions/deepFreeze.md @@ -22,6 +22,6 @@ deepFreeze(obj): U [packages/core/lib/utils/freeze.ts:1](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/utils/freeze.ts#L1) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/core/functions/removeSearchParams.md b/docs/api/core/functions/removeSearchParams.md index defbbf7..c4f2ffd 100644 --- a/docs/api/core/functions/removeSearchParams.md +++ b/docs/api/core/functions/removeSearchParams.md @@ -22,6 +22,6 @@ Removes the given search params from the URL completely; this is case-insensitiv [packages/core/lib/utils/url.ts:6](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/utils/url.ts#L6) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/core/index.md b/docs/api/core/index.md index 2258b26..6ad025c 100644 --- a/docs/api/core/index.md +++ b/docs/api/core/index.md @@ -6,38 +6,38 @@ ### Interfaces -| Interface | Description | -| :------ | :------ | -| [MapContext](interfaces/MapContext.md) | - | -| [MapContextBaseLayer](interfaces/MapContextBaseLayer.md) | - | -| [MapContextDiff](interfaces/MapContextDiff.md) | Describes a delta between two contexts, in order to be | -| [MapContextLayer](interfaces/MapContextLayer.md) | - | -| [MapContextLayerGeojson](interfaces/MapContextLayerGeojson.md) | - | +| Interface | Description | +| :------------------------------------------------------------------- | :------------------------------------------------------------- | +| [MapContext](interfaces/MapContext.md) | - | +| [MapContextBaseLayer](interfaces/MapContextBaseLayer.md) | - | +| [MapContextDiff](interfaces/MapContextDiff.md) | Describes a delta between two contexts, in order to be | +| [MapContextLayer](interfaces/MapContextLayer.md) | - | +| [MapContextLayerGeojson](interfaces/MapContextLayerGeojson.md) | - | | [MapContextLayerPositioned](interfaces/MapContextLayerPositioned.md) | Associates a position to a layer; the position is the index of | -| [MapContextLayerReordered](interfaces/MapContextLayerReordered.md) | Describes a layer being moved to a different position | -| [MapContextLayerWfs](interfaces/MapContextLayerWfs.md) | - | -| [MapContextLayerWms](interfaces/MapContextLayerWms.md) | - | -| [MapContextLayerWmts](interfaces/MapContextLayerWmts.md) | - | -| [MapContextLayerXyz](interfaces/MapContextLayerXyz.md) | - | -| [MapContextView](interfaces/MapContextView.md) | - | +| [MapContextLayerReordered](interfaces/MapContextLayerReordered.md) | Describes a layer being moved to a different position | +| [MapContextLayerWfs](interfaces/MapContextLayerWfs.md) | - | +| [MapContextLayerWms](interfaces/MapContextLayerWms.md) | - | +| [MapContextLayerWmts](interfaces/MapContextLayerWmts.md) | - | +| [MapContextLayerXyz](interfaces/MapContextLayerXyz.md) | - | +| [MapContextView](interfaces/MapContextView.md) | - | ### Type Aliases -| Type alias | Description | -| :------ | :------ | -| [Coordinate](type-aliases/Coordinate.md) | - | -| [Extent](type-aliases/Extent.md) | Min X, min Y, max X, max Y | -| [LayerDimensions](type-aliases/LayerDimensions.md) | - | -| [LayerExtras](type-aliases/LayerExtras.md) | - | +| Type alias | Description | +| :------------------------------------------------- | :------------------------- | +| [Coordinate](type-aliases/Coordinate.md) | - | +| [Extent](type-aliases/Extent.md) | Min X, min Y, max X, max Y | +| [LayerDimensions](type-aliases/LayerDimensions.md) | - | +| [LayerExtras](type-aliases/LayerExtras.md) | - | ### Functions -| Function | Description | -| :------ | :------ | -| [computeMapContextDiff](functions/computeMapContextDiff.md) | The following logic is produced by identifying layers in both context | -| [deepFreeze](functions/deepFreeze.md) | - | -| [removeSearchParams](functions/removeSearchParams.md) | Removes the given search params from the URL completely; this is case-insensitive | +| Function | Description | +| :---------------------------------------------------------- | :-------------------------------------------------------------------------------- | +| [computeMapContextDiff](functions/computeMapContextDiff.md) | The following logic is produced by identifying layers in both context | +| [deepFreeze](functions/deepFreeze.md) | - | +| [removeSearchParams](functions/removeSearchParams.md) | Removes the given search params from the URL completely; this is case-insensitive | -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/core/interfaces/MapContext.md b/docs/api/core/interfaces/MapContext.md index 5959bbf..6e480c2 100644 --- a/docs/api/core/interfaces/MapContext.md +++ b/docs/api/core/interfaces/MapContext.md @@ -14,7 +14,7 @@ layers: MapContextLayer[]; [packages/core/lib/model/map-context.ts:94](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L94) -*** +--- ### view @@ -26,6 +26,6 @@ view: MapContextView; [packages/core/lib/model/map-context.ts:95](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L95) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/core/interfaces/MapContextBaseLayer.md b/docs/api/core/interfaces/MapContextBaseLayer.md index b383b16..466bf4f 100644 --- a/docs/api/core/interfaces/MapContextBaseLayer.md +++ b/docs/api/core/interfaces/MapContextBaseLayer.md @@ -25,7 +25,7 @@ non-serializable entities [packages/core/lib/model/map-context.ts:16](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L16) -*** +--- ### id? @@ -37,7 +37,7 @@ id?: string | number; [packages/core/lib/model/map-context.ts:8](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L8) -*** +--- ### version? @@ -49,6 +49,6 @@ version?: number; [packages/core/lib/model/map-context.ts:9](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L9) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/core/interfaces/MapContextDiff.md b/docs/api/core/interfaces/MapContextDiff.md index f6ba9c9..58d397c 100644 --- a/docs/api/core/interfaces/MapContextDiff.md +++ b/docs/api/core/interfaces/MapContextDiff.md @@ -6,6 +6,7 @@ Describes a delta between two contexts, in order to be applied to an existing map. For positions to be correct the order of operations should be: + 1. change layers 2. remove layers 3. add layers @@ -23,7 +24,7 @@ layersAdded: MapContextLayerPositioned[]; [packages/core/lib/model/map-context-diff.ts:35](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context-diff.ts#L35) -*** +--- ### layersChanged @@ -35,7 +36,7 @@ layersChanged: MapContextLayerPositioned[]; [packages/core/lib/model/map-context-diff.ts:32](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context-diff.ts#L32) -*** +--- ### layersRemoved @@ -47,7 +48,7 @@ layersRemoved: MapContextLayerPositioned[]; [packages/core/lib/model/map-context-diff.ts:34](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context-diff.ts#L34) -*** +--- ### layersReordered @@ -59,7 +60,7 @@ layersReordered: MapContextLayerReordered[]; [packages/core/lib/model/map-context-diff.ts:33](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context-diff.ts#L33) -*** +--- ### viewChanges @@ -71,6 +72,6 @@ viewChanges: MapContextView; [packages/core/lib/model/map-context-diff.ts:36](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context-diff.ts#L36) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/core/interfaces/MapContextLayer.md b/docs/api/core/interfaces/MapContextLayer.md index 6c808e6..29d06ea 100644 --- a/docs/api/core/interfaces/MapContextLayer.md +++ b/docs/api/core/interfaces/MapContextLayer.md @@ -18,7 +18,7 @@ non-serializable entities [packages/core/lib/model/map-context.ts:16](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L16) -*** +--- ### id? @@ -30,12 +30,12 @@ id?: string | number; [packages/core/lib/model/map-context.ts:8](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L8) -*** +--- ### type ```ts -type: +type: | "wms" | "wmts" | "wfs" @@ -47,7 +47,7 @@ type: [packages/core/lib/model/map-context.ts:20](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L20) -*** +--- ### url? @@ -59,7 +59,7 @@ url?: string; [packages/core/lib/model/map-context.ts:21](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L21) -*** +--- ### version? @@ -71,6 +71,6 @@ version?: number; [packages/core/lib/model/map-context.ts:9](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L9) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/core/interfaces/MapContextLayerGeojson.md b/docs/api/core/interfaces/MapContextLayerGeojson.md index aa43214..f2ecb40 100644 --- a/docs/api/core/interfaces/MapContextLayerGeojson.md +++ b/docs/api/core/interfaces/MapContextLayerGeojson.md @@ -14,7 +14,7 @@ data?: string | FeatureCollection; [packages/core/lib/model/map-context.ts:51](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L51) -*** +--- ### extras? @@ -30,7 +30,7 @@ non-serializable entities [packages/core/lib/model/map-context.ts:16](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L16) -*** +--- ### id? @@ -42,7 +42,7 @@ id?: string | number; [packages/core/lib/model/map-context.ts:8](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L8) -*** +--- ### type @@ -54,7 +54,7 @@ type: "geojson"; [packages/core/lib/model/map-context.ts:47](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L47) -*** +--- ### url? @@ -66,7 +66,7 @@ url?: string; [packages/core/lib/model/map-context.ts:50](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L50) -*** +--- ### version? @@ -78,6 +78,6 @@ version?: number; [packages/core/lib/model/map-context.ts:9](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L9) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/core/interfaces/MapContextLayerPositioned.md b/docs/api/core/interfaces/MapContextLayerPositioned.md index bcce78e..b190a36 100644 --- a/docs/api/core/interfaces/MapContextLayerPositioned.md +++ b/docs/api/core/interfaces/MapContextLayerPositioned.md @@ -17,7 +17,7 @@ layer: MapContextLayer; [packages/core/lib/model/map-context-diff.ts:8](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context-diff.ts#L8) -*** +--- ### position @@ -29,6 +29,6 @@ position: number; [packages/core/lib/model/map-context-diff.ts:9](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context-diff.ts#L9) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/core/interfaces/MapContextLayerReordered.md b/docs/api/core/interfaces/MapContextLayerReordered.md index 2e0645e..a82942a 100644 --- a/docs/api/core/interfaces/MapContextLayerReordered.md +++ b/docs/api/core/interfaces/MapContextLayerReordered.md @@ -16,7 +16,7 @@ layer: MapContextLayer; [packages/core/lib/model/map-context-diff.ts:16](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context-diff.ts#L16) -*** +--- ### newPosition @@ -28,7 +28,7 @@ newPosition: number; [packages/core/lib/model/map-context-diff.ts:17](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context-diff.ts#L17) -*** +--- ### previousPosition @@ -40,6 +40,6 @@ previousPosition: number; [packages/core/lib/model/map-context-diff.ts:18](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context-diff.ts#L18) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/core/interfaces/MapContextLayerWfs.md b/docs/api/core/interfaces/MapContextLayerWfs.md index 9a33055..5ced10d 100644 --- a/docs/api/core/interfaces/MapContextLayerWfs.md +++ b/docs/api/core/interfaces/MapContextLayerWfs.md @@ -26,7 +26,7 @@ non-serializable entities [packages/core/lib/model/map-context.ts:16](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L16) -*** +--- ### featureType @@ -38,7 +38,7 @@ featureType: string; [packages/core/lib/model/map-context.ts:38](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L38) -*** +--- ### id? @@ -54,7 +54,7 @@ id?: string | number; [packages/core/lib/model/map-context.ts:8](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L8) -*** +--- ### type @@ -66,7 +66,7 @@ type: "wfs"; [packages/core/lib/model/map-context.ts:36](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L36) -*** +--- ### url @@ -78,7 +78,7 @@ url: string; [packages/core/lib/model/map-context.ts:37](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L37) -*** +--- ### version? @@ -94,6 +94,6 @@ version?: number; [packages/core/lib/model/map-context.ts:9](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L9) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/core/interfaces/MapContextLayerWms.md b/docs/api/core/interfaces/MapContextLayerWms.md index bf6e891..fc68ee8 100644 --- a/docs/api/core/interfaces/MapContextLayerWms.md +++ b/docs/api/core/interfaces/MapContextLayerWms.md @@ -18,7 +18,7 @@ dimensions?: LayerDimensions; [packages/core/lib/model/map-context.ts:23](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L23) -*** +--- ### extras? @@ -38,7 +38,7 @@ non-serializable entities [packages/core/lib/model/map-context.ts:16](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L16) -*** +--- ### id? @@ -54,7 +54,7 @@ id?: string | number; [packages/core/lib/model/map-context.ts:8](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L8) -*** +--- ### name @@ -66,7 +66,7 @@ name: string; [packages/core/lib/model/map-context.ts:22](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L22) -*** +--- ### style? @@ -78,7 +78,7 @@ style?: string; [packages/core/lib/model/map-context.ts:24](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L24) -*** +--- ### type @@ -90,7 +90,7 @@ type: "wms"; [packages/core/lib/model/map-context.ts:20](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L20) -*** +--- ### url @@ -102,7 +102,7 @@ url: string; [packages/core/lib/model/map-context.ts:21](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L21) -*** +--- ### version? @@ -118,6 +118,6 @@ version?: number; [packages/core/lib/model/map-context.ts:9](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L9) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/core/interfaces/MapContextLayerWmts.md b/docs/api/core/interfaces/MapContextLayerWmts.md index 14b85c1..8467db8 100644 --- a/docs/api/core/interfaces/MapContextLayerWmts.md +++ b/docs/api/core/interfaces/MapContextLayerWmts.md @@ -18,7 +18,7 @@ dimensions?: LayerDimensions; [packages/core/lib/model/map-context.ts:31](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L31) -*** +--- ### extras? @@ -38,7 +38,7 @@ non-serializable entities [packages/core/lib/model/map-context.ts:16](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L16) -*** +--- ### id? @@ -54,7 +54,7 @@ id?: string | number; [packages/core/lib/model/map-context.ts:8](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L8) -*** +--- ### name @@ -66,7 +66,7 @@ name: string; [packages/core/lib/model/map-context.ts:30](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L30) -*** +--- ### style? @@ -78,7 +78,7 @@ style?: string; [packages/core/lib/model/map-context.ts:32](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L32) -*** +--- ### type @@ -90,7 +90,7 @@ type: "wmts"; [packages/core/lib/model/map-context.ts:28](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L28) -*** +--- ### url @@ -102,7 +102,7 @@ url: string; [packages/core/lib/model/map-context.ts:29](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L29) -*** +--- ### version? @@ -118,6 +118,6 @@ version?: number; [packages/core/lib/model/map-context.ts:9](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L9) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/core/interfaces/MapContextLayerXyz.md b/docs/api/core/interfaces/MapContextLayerXyz.md index 2d9bcfa..236797b 100644 --- a/docs/api/core/interfaces/MapContextLayerXyz.md +++ b/docs/api/core/interfaces/MapContextLayerXyz.md @@ -26,7 +26,7 @@ non-serializable entities [packages/core/lib/model/map-context.ts:16](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L16) -*** +--- ### id? @@ -42,7 +42,7 @@ id?: string | number; [packages/core/lib/model/map-context.ts:8](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L8) -*** +--- ### type @@ -54,7 +54,7 @@ type: "xyz"; [packages/core/lib/model/map-context.ts:42](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L42) -*** +--- ### url @@ -66,7 +66,7 @@ url: string; [packages/core/lib/model/map-context.ts:43](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L43) -*** +--- ### version? @@ -82,6 +82,6 @@ version?: number; [packages/core/lib/model/map-context.ts:9](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L9) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/core/interfaces/MapContextView.md b/docs/api/core/interfaces/MapContextView.md index 00516df..e29d14f 100644 --- a/docs/api/core/interfaces/MapContextView.md +++ b/docs/api/core/interfaces/MapContextView.md @@ -16,7 +16,7 @@ Expressed in longitude/latitude [packages/core/lib/model/map-context.ts:86](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L86) -*** +--- ### extent? @@ -30,7 +30,7 @@ Expressed in longitude/latitude [packages/core/lib/model/map-context.ts:88](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L88) -*** +--- ### maxExtent? @@ -44,7 +44,7 @@ Expressed in longitude/latitude [packages/core/lib/model/map-context.ts:90](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L90) -*** +--- ### maxZoom? @@ -56,7 +56,7 @@ maxZoom?: number; [packages/core/lib/model/map-context.ts:89](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L89) -*** +--- ### zoom? @@ -68,6 +68,6 @@ zoom?: number; [packages/core/lib/model/map-context.ts:87](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L87) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/core/type-aliases/Coordinate.md b/docs/api/core/type-aliases/Coordinate.md index 709b9bf..f6fd143 100644 --- a/docs/api/core/type-aliases/Coordinate.md +++ b/docs/api/core/type-aliases/Coordinate.md @@ -10,6 +10,6 @@ type Coordinate: [number, number]; [packages/core/lib/model/map-context.ts:73](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L73) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/core/type-aliases/Extent.md b/docs/api/core/type-aliases/Extent.md index 55e0ae1..b2569e0 100644 --- a/docs/api/core/type-aliases/Extent.md +++ b/docs/api/core/type-aliases/Extent.md @@ -12,6 +12,6 @@ Min X, min Y, max X, max Y [packages/core/lib/model/map-context.ts:78](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L78) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/core/type-aliases/LayerDimensions.md b/docs/api/core/type-aliases/LayerDimensions.md index c3fbdfb..a465fd9 100644 --- a/docs/api/core/type-aliases/LayerDimensions.md +++ b/docs/api/core/type-aliases/LayerDimensions.md @@ -10,6 +10,6 @@ type LayerDimensions: Record; [packages/core/lib/model/map-context.ts:3](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L3) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/core/type-aliases/LayerExtras.md b/docs/api/core/type-aliases/LayerExtras.md index defa8ed..2beef08 100644 --- a/docs/api/core/type-aliases/LayerExtras.md +++ b/docs/api/core/type-aliases/LayerExtras.md @@ -10,6 +10,6 @@ type LayerExtras: Record; [packages/core/lib/model/map-context.ts:5](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/core/lib/model/map-context.ts#L5) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/geocoding/functions/queryDataGouvFr.md b/docs/api/geocoding/functions/queryDataGouvFr.md index 8d7c2c2..a09ae2f 100644 --- a/docs/api/geocoding/functions/queryDataGouvFr.md +++ b/docs/api/geocoding/functions/queryDataGouvFr.md @@ -20,6 +20,6 @@ queryDataGouvFr(input, options?): Promise [packages/geocoding/lib/providers/data-gouv-fr.provider.ts:53](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/geocoding/lib/providers/data-gouv-fr.provider.ts#L53) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/geocoding/functions/queryGeoadmin.md b/docs/api/geocoding/functions/queryGeoadmin.md index 6686e82..045f8cc 100644 --- a/docs/api/geocoding/functions/queryGeoadmin.md +++ b/docs/api/geocoding/functions/queryGeoadmin.md @@ -20,6 +20,6 @@ queryGeoadmin(input, options?): Promise [packages/geocoding/lib/providers/geoadmin.provider.ts:35](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/geocoding/lib/providers/geoadmin.provider.ts#L35) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/geocoding/index.md b/docs/api/geocoding/index.md index e5ef117..406576a 100644 --- a/docs/api/geocoding/index.md +++ b/docs/api/geocoding/index.md @@ -6,18 +6,18 @@ ### Interfaces -| Interface | Description | -| :------ | :------ | -| [DataGouvFrOptions](interfaces/DataGouvFrOptions.md) | Reference documentation: https://adresse.data.gouv.fr/api-doc/adresse | -| [GeoadminOptions](interfaces/GeoadminOptions.md) | Reference documentation: https://api3.geo.admin.ch/services/sdiservices.html#search | +| Interface | Description | +| :--------------------------------------------------- | :---------------------------------------------------------------------------------- | +| [DataGouvFrOptions](interfaces/DataGouvFrOptions.md) | Reference documentation: https://adresse.data.gouv.fr/api-doc/adresse | +| [GeoadminOptions](interfaces/GeoadminOptions.md) | Reference documentation: https://api3.geo.admin.ch/services/sdiservices.html#search | ### Functions -| Function | Description | -| :------ | :------ | -| [queryDataGouvFr](functions/queryDataGouvFr.md) | - | -| [queryGeoadmin](functions/queryGeoadmin.md) | - | +| Function | Description | +| :---------------------------------------------- | :---------- | +| [queryDataGouvFr](functions/queryDataGouvFr.md) | - | +| [queryGeoadmin](functions/queryGeoadmin.md) | - | -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/geocoding/interfaces/DataGouvFrOptions.md b/docs/api/geocoding/interfaces/DataGouvFrOptions.md index b0b4bc4..e1921e9 100644 --- a/docs/api/geocoding/interfaces/DataGouvFrOptions.md +++ b/docs/api/geocoding/interfaces/DataGouvFrOptions.md @@ -16,7 +16,7 @@ cityCode?: string; [packages/geocoding/lib/providers/data-gouv-fr.provider.ts:49](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/geocoding/lib/providers/data-gouv-fr.provider.ts#L49) -*** +--- ### limit? @@ -30,7 +30,7 @@ Default value 15 [packages/geocoding/lib/providers/data-gouv-fr.provider.ts:50](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/geocoding/lib/providers/data-gouv-fr.provider.ts#L50) -*** +--- ### postCode? @@ -42,7 +42,7 @@ postCode?: string; [packages/geocoding/lib/providers/data-gouv-fr.provider.ts:48](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/geocoding/lib/providers/data-gouv-fr.provider.ts#L48) -*** +--- ### type? @@ -54,6 +54,6 @@ type?: "housenumber" | "street" | "locality" | "municipality"; [packages/geocoding/lib/providers/data-gouv-fr.provider.ts:47](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/geocoding/lib/providers/data-gouv-fr.provider.ts#L47) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/geocoding/interfaces/GeoadminOptions.md b/docs/api/geocoding/interfaces/GeoadminOptions.md index ef5c18f..aac7f13 100644 --- a/docs/api/geocoding/interfaces/GeoadminOptions.md +++ b/docs/api/geocoding/interfaces/GeoadminOptions.md @@ -18,12 +18,12 @@ A list of technical layer names; only applies when type is 'featuresearch' [packages/geocoding/lib/providers/geoadmin.provider.ts:32](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/geocoding/lib/providers/geoadmin.provider.ts#L32) -*** +--- ### lang? ```ts -lang?: +lang?: | "it" | "de" | "fr" @@ -37,7 +37,7 @@ Default is 'en' [packages/geocoding/lib/providers/geoadmin.provider.ts:31](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/geocoding/lib/providers/geoadmin.provider.ts#L31) -*** +--- ### limit? @@ -51,7 +51,7 @@ Default value is 50 for 'locations', 20 for 'featuresearch', 30 for 'layers' [packages/geocoding/lib/providers/geoadmin.provider.ts:30](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/geocoding/lib/providers/geoadmin.provider.ts#L30) -*** +--- ### origins? @@ -72,7 +72,7 @@ Defaults to 'zipcode,gg25'; only applies when type is 'locations' [packages/geocoding/lib/providers/geoadmin.provider.ts:21](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/geocoding/lib/providers/geoadmin.provider.ts#L21) -*** +--- ### sr? @@ -86,7 +86,7 @@ Defaults to 4326 [packages/geocoding/lib/providers/geoadmin.provider.ts:20](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/geocoding/lib/providers/geoadmin.provider.ts#L20) -*** +--- ### type? @@ -100,6 +100,6 @@ Default is 'locations' [packages/geocoding/lib/providers/geoadmin.provider.ts:19](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/geocoding/lib/providers/geoadmin.provider.ts#L19) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/index.md b/docs/api/index.md index c9fef25..4f1da38 100644 --- a/docs/api/index.md +++ b/docs/api/index.md @@ -2,12 +2,12 @@ ## Modules -| Module | Description | -| :------ | :------ | -| [core](core/index.md) | - | -| [geocoding](geocoding/index.md) | - | -| [openlayers](openlayers/index.md) | - | +| Module | Description | +| :-------------------------------- | :---------- | +| [core](core/index.md) | - | +| [geocoding](geocoding/index.md) | - | +| [openlayers](openlayers/index.md) | - | -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/openlayers/functions/createGeometryStyles.md b/docs/api/openlayers/functions/createGeometryStyles.md index 3d77032..e3e473b 100644 --- a/docs/api/openlayers/functions/createGeometryStyles.md +++ b/docs/api/openlayers/functions/createGeometryStyles.md @@ -18,6 +18,6 @@ createGeometryStyles(options): StyleByGeometryType [packages/openlayers/lib/map/styles.ts:17](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/openlayers/lib/map/styles.ts#L17) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/openlayers/functions/createMapFromContext.md b/docs/api/openlayers/functions/createMapFromContext.md index bfcbfee..7d9195e 100644 --- a/docs/api/openlayers/functions/createMapFromContext.md +++ b/docs/api/openlayers/functions/createMapFromContext.md @@ -20,6 +20,6 @@ Create an OpenLayers map from a context [packages/openlayers/lib/map/create-map.ts:133](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/openlayers/lib/map/create-map.ts#L133) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/openlayers/functions/createStyleFunction.md b/docs/api/openlayers/functions/createStyleFunction.md index 6391dad..2473e90 100644 --- a/docs/api/openlayers/functions/createStyleFunction.md +++ b/docs/api/openlayers/functions/createStyleFunction.md @@ -18,6 +18,6 @@ createStyleFunction(styleByGeometryType): StyleFunction [packages/openlayers/lib/map/styles.ts:65](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/openlayers/lib/map/styles.ts#L65) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/openlayers/functions/defaultHighlightStyle.md b/docs/api/openlayers/functions/defaultHighlightStyle.md index d259bff..ab79d9a 100644 --- a/docs/api/openlayers/functions/defaultHighlightStyle.md +++ b/docs/api/openlayers/functions/defaultHighlightStyle.md @@ -20,6 +20,6 @@ defaultHighlightStyle(arg0, arg1): void | Style | Style[] [packages/openlayers/lib/map/styles.ts:98](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/openlayers/lib/map/styles.ts#L98) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/openlayers/functions/defaultStyle.md b/docs/api/openlayers/functions/defaultStyle.md index 94d0e62..ec93cb7 100644 --- a/docs/api/openlayers/functions/defaultStyle.md +++ b/docs/api/openlayers/functions/defaultStyle.md @@ -20,6 +20,6 @@ defaultStyle(arg0, arg1): void | Style | Style[] [packages/openlayers/lib/map/styles.ts:92](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/openlayers/lib/map/styles.ts#L92) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/openlayers/functions/resetMapFromContext.md b/docs/api/openlayers/functions/resetMapFromContext.md index ecb8da4..ab83d28 100644 --- a/docs/api/openlayers/functions/resetMapFromContext.md +++ b/docs/api/openlayers/functions/resetMapFromContext.md @@ -22,6 +22,6 @@ Resets an OpenLayers map from a context; existing content will be cleared [packages/openlayers/lib/map/create-map.ts:143](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/openlayers/lib/map/create-map.ts#L143) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/openlayers/index.md b/docs/api/openlayers/index.md index 53bf47a..4d2028b 100644 --- a/docs/api/openlayers/index.md +++ b/docs/api/openlayers/index.md @@ -6,22 +6,22 @@ ### Interfaces -| Interface | Description | -| :------ | :------ | -| [CreateStyleOptions](interfaces/CreateStyleOptions.md) | - | -| [StyleByGeometryType](interfaces/StyleByGeometryType.md) | - | +| Interface | Description | +| :------------------------------------------------------- | :---------- | +| [CreateStyleOptions](interfaces/CreateStyleOptions.md) | - | +| [StyleByGeometryType](interfaces/StyleByGeometryType.md) | - | ### Functions -| Function | Description | -| :------ | :------ | -| [createGeometryStyles](functions/createGeometryStyles.md) | - | -| [createMapFromContext](functions/createMapFromContext.md) | Create an OpenLayers map from a context | -| [createStyleFunction](functions/createStyleFunction.md) | - | -| [defaultHighlightStyle](functions/defaultHighlightStyle.md) | - | -| [defaultStyle](functions/defaultStyle.md) | - | -| [resetMapFromContext](functions/resetMapFromContext.md) | Resets an OpenLayers map from a context; existing content will be cleared | +| Function | Description | +| :---------------------------------------------------------- | :------------------------------------------------------------------------ | +| [createGeometryStyles](functions/createGeometryStyles.md) | - | +| [createMapFromContext](functions/createMapFromContext.md) | Create an OpenLayers map from a context | +| [createStyleFunction](functions/createStyleFunction.md) | - | +| [defaultHighlightStyle](functions/defaultHighlightStyle.md) | - | +| [defaultStyle](functions/defaultStyle.md) | - | +| [resetMapFromContext](functions/resetMapFromContext.md) | Resets an OpenLayers map from a context; existing content will be cleared | -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/openlayers/interfaces/CreateStyleOptions.md b/docs/api/openlayers/interfaces/CreateStyleOptions.md index f52df90..1b60b3f 100644 --- a/docs/api/openlayers/interfaces/CreateStyleOptions.md +++ b/docs/api/openlayers/interfaces/CreateStyleOptions.md @@ -14,7 +14,7 @@ color: string; [packages/openlayers/lib/map/styles.ts:7](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/openlayers/lib/map/styles.ts#L7) -*** +--- ### isFocused? @@ -26,6 +26,6 @@ isFocused?: boolean; [packages/openlayers/lib/map/styles.ts:8](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/openlayers/lib/map/styles.ts#L8) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/openlayers/interfaces/StyleByGeometryType.md b/docs/api/openlayers/interfaces/StyleByGeometryType.md index 7171a42..014ef65 100644 --- a/docs/api/openlayers/interfaces/StyleByGeometryType.md +++ b/docs/api/openlayers/interfaces/StyleByGeometryType.md @@ -14,7 +14,7 @@ line: Style | Style[]; [packages/openlayers/lib/map/styles.ts:12](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/openlayers/lib/map/styles.ts#L12) -*** +--- ### point @@ -26,7 +26,7 @@ point: Style | Style[]; [packages/openlayers/lib/map/styles.ts:14](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/openlayers/lib/map/styles.ts#L14) -*** +--- ### polygon @@ -38,6 +38,6 @@ polygon: Style | Style[]; [packages/openlayers/lib/map/styles.ts:13](https://github.com/jahow/geospatial-sdk/blob/eda8b4f/packages/openlayers/lib/map/styles.ts#L13) -*** +--- Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/docs/api/typedoc-sidebar.json b/docs/api/typedoc-sidebar.json index 324369f..fa1636e 100644 --- a/docs/api/typedoc-sidebar.json +++ b/docs/api/typedoc-sidebar.json @@ -1 +1,183 @@ -[{"text":"core","link":"/api/core/index.md","collapsed":true,"items":[{"text":"Interfaces","collapsed":true,"items":[{"text":"MapContext","link":"/api/core/interfaces/MapContext.md"},{"text":"MapContextBaseLayer","link":"/api/core/interfaces/MapContextBaseLayer.md"},{"text":"MapContextDiff","link":"/api/core/interfaces/MapContextDiff.md"},{"text":"MapContextLayer","link":"/api/core/interfaces/MapContextLayer.md"},{"text":"MapContextLayerGeojson","link":"/api/core/interfaces/MapContextLayerGeojson.md"},{"text":"MapContextLayerPositioned","link":"/api/core/interfaces/MapContextLayerPositioned.md"},{"text":"MapContextLayerReordered","link":"/api/core/interfaces/MapContextLayerReordered.md"},{"text":"MapContextLayerWfs","link":"/api/core/interfaces/MapContextLayerWfs.md"},{"text":"MapContextLayerWms","link":"/api/core/interfaces/MapContextLayerWms.md"},{"text":"MapContextLayerWmts","link":"/api/core/interfaces/MapContextLayerWmts.md"},{"text":"MapContextLayerXyz","link":"/api/core/interfaces/MapContextLayerXyz.md"},{"text":"MapContextView","link":"/api/core/interfaces/MapContextView.md"}]},{"text":"Type Aliases","collapsed":true,"items":[{"text":"Coordinate","link":"/api/core/type-aliases/Coordinate.md"},{"text":"Extent","link":"/api/core/type-aliases/Extent.md"},{"text":"LayerDimensions","link":"/api/core/type-aliases/LayerDimensions.md"},{"text":"LayerExtras","link":"/api/core/type-aliases/LayerExtras.md"}]},{"text":"Functions","collapsed":true,"items":[{"text":"computeMapContextDiff","link":"/api/core/functions/computeMapContextDiff.md"},{"text":"deepFreeze","link":"/api/core/functions/deepFreeze.md"},{"text":"removeSearchParams","link":"/api/core/functions/removeSearchParams.md"}]}]},{"text":"geocoding","link":"/api/geocoding/index.md","collapsed":true,"items":[{"text":"Interfaces","collapsed":true,"items":[{"text":"DataGouvFrOptions","link":"/api/geocoding/interfaces/DataGouvFrOptions.md"},{"text":"GeoadminOptions","link":"/api/geocoding/interfaces/GeoadminOptions.md"}]},{"text":"Functions","collapsed":true,"items":[{"text":"queryDataGouvFr","link":"/api/geocoding/functions/queryDataGouvFr.md"},{"text":"queryGeoadmin","link":"/api/geocoding/functions/queryGeoadmin.md"}]}]},{"text":"openlayers","link":"/api/openlayers/index.md","collapsed":true,"items":[{"text":"Interfaces","collapsed":true,"items":[{"text":"CreateStyleOptions","link":"/api/openlayers/interfaces/CreateStyleOptions.md"},{"text":"StyleByGeometryType","link":"/api/openlayers/interfaces/StyleByGeometryType.md"}]},{"text":"Functions","collapsed":true,"items":[{"text":"createGeometryStyles","link":"/api/openlayers/functions/createGeometryStyles.md"},{"text":"createMapFromContext","link":"/api/openlayers/functions/createMapFromContext.md"},{"text":"createStyleFunction","link":"/api/openlayers/functions/createStyleFunction.md"},{"text":"defaultHighlightStyle","link":"/api/openlayers/functions/defaultHighlightStyle.md"},{"text":"defaultStyle","link":"/api/openlayers/functions/defaultStyle.md"},{"text":"resetMapFromContext","link":"/api/openlayers/functions/resetMapFromContext.md"}]}]}] \ No newline at end of file +[ + { + "text": "core", + "link": "/api/core/index.md", + "collapsed": true, + "items": [ + { + "text": "Interfaces", + "collapsed": true, + "items": [ + { + "text": "MapContext", + "link": "/api/core/interfaces/MapContext.md" + }, + { + "text": "MapContextBaseLayer", + "link": "/api/core/interfaces/MapContextBaseLayer.md" + }, + { + "text": "MapContextDiff", + "link": "/api/core/interfaces/MapContextDiff.md" + }, + { + "text": "MapContextLayer", + "link": "/api/core/interfaces/MapContextLayer.md" + }, + { + "text": "MapContextLayerGeojson", + "link": "/api/core/interfaces/MapContextLayerGeojson.md" + }, + { + "text": "MapContextLayerPositioned", + "link": "/api/core/interfaces/MapContextLayerPositioned.md" + }, + { + "text": "MapContextLayerReordered", + "link": "/api/core/interfaces/MapContextLayerReordered.md" + }, + { + "text": "MapContextLayerWfs", + "link": "/api/core/interfaces/MapContextLayerWfs.md" + }, + { + "text": "MapContextLayerWms", + "link": "/api/core/interfaces/MapContextLayerWms.md" + }, + { + "text": "MapContextLayerWmts", + "link": "/api/core/interfaces/MapContextLayerWmts.md" + }, + { + "text": "MapContextLayerXyz", + "link": "/api/core/interfaces/MapContextLayerXyz.md" + }, + { + "text": "MapContextView", + "link": "/api/core/interfaces/MapContextView.md" + } + ] + }, + { + "text": "Type Aliases", + "collapsed": true, + "items": [ + { + "text": "Coordinate", + "link": "/api/core/type-aliases/Coordinate.md" + }, + { "text": "Extent", "link": "/api/core/type-aliases/Extent.md" }, + { + "text": "LayerDimensions", + "link": "/api/core/type-aliases/LayerDimensions.md" + }, + { + "text": "LayerExtras", + "link": "/api/core/type-aliases/LayerExtras.md" + } + ] + }, + { + "text": "Functions", + "collapsed": true, + "items": [ + { + "text": "computeMapContextDiff", + "link": "/api/core/functions/computeMapContextDiff.md" + }, + { "text": "deepFreeze", "link": "/api/core/functions/deepFreeze.md" }, + { + "text": "removeSearchParams", + "link": "/api/core/functions/removeSearchParams.md" + } + ] + } + ] + }, + { + "text": "geocoding", + "link": "/api/geocoding/index.md", + "collapsed": true, + "items": [ + { + "text": "Interfaces", + "collapsed": true, + "items": [ + { + "text": "DataGouvFrOptions", + "link": "/api/geocoding/interfaces/DataGouvFrOptions.md" + }, + { + "text": "GeoadminOptions", + "link": "/api/geocoding/interfaces/GeoadminOptions.md" + } + ] + }, + { + "text": "Functions", + "collapsed": true, + "items": [ + { + "text": "queryDataGouvFr", + "link": "/api/geocoding/functions/queryDataGouvFr.md" + }, + { + "text": "queryGeoadmin", + "link": "/api/geocoding/functions/queryGeoadmin.md" + } + ] + } + ] + }, + { + "text": "openlayers", + "link": "/api/openlayers/index.md", + "collapsed": true, + "items": [ + { + "text": "Interfaces", + "collapsed": true, + "items": [ + { + "text": "CreateStyleOptions", + "link": "/api/openlayers/interfaces/CreateStyleOptions.md" + }, + { + "text": "StyleByGeometryType", + "link": "/api/openlayers/interfaces/StyleByGeometryType.md" + } + ] + }, + { + "text": "Functions", + "collapsed": true, + "items": [ + { + "text": "createGeometryStyles", + "link": "/api/openlayers/functions/createGeometryStyles.md" + }, + { + "text": "createMapFromContext", + "link": "/api/openlayers/functions/createMapFromContext.md" + }, + { + "text": "createStyleFunction", + "link": "/api/openlayers/functions/createStyleFunction.md" + }, + { + "text": "defaultHighlightStyle", + "link": "/api/openlayers/functions/defaultHighlightStyle.md" + }, + { + "text": "defaultStyle", + "link": "/api/openlayers/functions/defaultStyle.md" + }, + { + "text": "resetMapFromContext", + "link": "/api/openlayers/functions/resetMapFromContext.md" + } + ] + } + ] + } +] diff --git a/package-lock.json b/package-lock.json index 50f6441..2b81c01 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4149,6 +4149,21 @@ "integrity": "sha512-yg6E+u0/+Zjva+buc3EIb+29XEg4wltq7cSmd4Uc2EE/1nUVmxyzpX6gUXD0V8jIrG0r7YeOGVIbYRkxeooCtw==", "dev": true }, + "node_modules/@types/lodash": { + "version": "4.17.7", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.7.tgz", + "integrity": "sha512-8wTvZawATi/lsmNu10/j2hk1KEP0IvjubqPE3cu1Xz7xfXXt5oCq3SNUz4fMIP4XGF9Ky+Ue2tBA3hcS7LSBlA==", + "dev": true + }, + "node_modules/@types/lodash.throttle": { + "version": "4.1.9", + "resolved": "https://registry.npmjs.org/@types/lodash.throttle/-/lodash.throttle-4.1.9.tgz", + "integrity": "sha512-PCPVfpfueguWZQB7pJQK890F2scYKoDUL3iM522AptHWn7d5NQmeS/LTEHIcLr5PaTzl3dK2Z0xSUHHTHwaL5g==", + "dev": true, + "dependencies": { + "@types/lodash": "*" + } + }, "node_modules/@types/markdown-it": { "version": "13.0.7", "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-13.0.7.tgz", @@ -8891,6 +8906,11 @@ "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true }, + "node_modules/lodash.throttle": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.throttle/-/lodash.throttle-4.1.1.tgz", + "integrity": "sha512-wIkUCfVKpVsWo3JSZlc+8MB5it+2AN5W8J7YVMST30UrvcQNZ1Okbj+rbVniijTWE6FGYy4XJq/rHkas8qJMLQ==" + }, "node_modules/log-symbols": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", @@ -14173,10 +14193,12 @@ "license": "BSD-3-Clause", "dependencies": { "@geospatial-sdk/core": "^0.0.5-alpha.2", - "chroma-js": "^2.4.2" + "chroma-js": "^2.4.2", + "lodash.throttle": "^4.1.1" }, "devDependencies": { "@types/chroma-js": "^2.4.3", + "@types/lodash.throttle": "^4.1.9", "ol": "^8.2.0", "ol-mapbox-style": "^12.3.5" }, diff --git a/packages/core/fixtures/map-context.fixtures.ts b/packages/core/fixtures/map-context.fixtures.ts index d57283d..4785381 100644 --- a/packages/core/fixtures/map-context.fixtures.ts +++ b/packages/core/fixtures/map-context.fixtures.ts @@ -25,6 +25,7 @@ export const MAP_CTX_LAYER_WMS_FIXTURE: MapContextLayerWms = deepFreeze({ visibility: false, attributions: "camptocamp", opacity: 0.5, + style: "default", }); export const MAP_CTX_LAYER_WFS_FIXTURE: MapContextLayerWfs = deepFreeze({ type: "wfs", diff --git a/packages/core/lib/model/events.ts b/packages/core/lib/model/events.ts new file mode 100644 index 0000000..2383494 --- /dev/null +++ b/packages/core/lib/model/events.ts @@ -0,0 +1,23 @@ +import { Feature } from "geojson"; + +export const FeaturesClickEventType = "features-click"; +export interface FeaturesClickEvent { + features: Feature[]; +} + +export const FeaturesHoverEventType = "features-hover"; +export interface FeaturesHoverEvent { + features: Feature[]; +} + +export const MapClickEventType = "map-click"; +export interface MapClickEvent { + coordinate: [number, number]; // expressed in lon/lat +} + +export type MapEvent = FeaturesClickEvent | FeaturesHoverEvent | MapClickEvent; + +export type MapEventType = + | typeof FeaturesClickEventType + | typeof FeaturesHoverEventType + | typeof MapClickEventType; diff --git a/packages/core/lib/model/index.ts b/packages/core/lib/model/index.ts index dca6892..1dda158 100644 --- a/packages/core/lib/model/index.ts +++ b/packages/core/lib/model/index.ts @@ -1,2 +1,3 @@ export * from "./map-context"; export * from "./map-context-diff"; +export * from "./events"; diff --git a/packages/core/lib/utils/view.ts b/packages/core/lib/utils/view.ts index 85f2d51..6a18813 100644 --- a/packages/core/lib/utils/view.ts +++ b/packages/core/lib/utils/view.ts @@ -9,6 +9,7 @@ import proj4 from "proj4"; import { Extent, MapContextLayer, + MapContextLayerWfs, MapContextLayerWms, MapContextLayerWmts, MapContextView, @@ -94,7 +95,9 @@ async function getWmtsLayerExtent( : null; } -async function getWfsLayerExtent(layer: any): Promise { +async function getWfsLayerExtent( + layer: MapContextLayerWfs, +): Promise { const endpoint = await new WfsEndpoint(layer.url).isReady(); const featureTypeSummary = endpoint.getFeatureTypeSummary(layer.featureType); const boundingBox = featureTypeSummary?.boundingBox; diff --git a/packages/openlayers/lib/map/create-map.test.ts b/packages/openlayers/lib/map/create-map.test.ts index 0eabb1b..732f170 100644 --- a/packages/openlayers/lib/map/create-map.test.ts +++ b/packages/openlayers/lib/map/create-map.test.ts @@ -119,6 +119,7 @@ describe("MapContextService", () => { const source = layer.getSource() as TileWMS; const params = source.getParams(); expect(params.LAYERS).toBe((layerModel as MapContextLayerWms).name); + expect(params.STYLES).toBe((layerModel as MapContextLayerWms).style); }); it("set correct url without existing REQUEST and SERVICE params", () => { const source = layer.getSource() as TileWMS; diff --git a/packages/openlayers/lib/map/create-map.ts b/packages/openlayers/lib/map/create-map.ts index 7bc257d..736d7d0 100644 --- a/packages/openlayers/lib/map/create-map.ts +++ b/packages/openlayers/lib/map/create-map.ts @@ -49,7 +49,10 @@ export async function createLayer(layerModel: MapContextLayer): Promise { layer = new TileLayer({ source: new TileWMS({ url: removeSearchParams(layerModel.url, ["request", "service"]), - params: { LAYERS: layerModel.name }, + params: { + LAYERS: layerModel.name, + ...(layerModel.style && { STYLES: layerModel.style }), + }, gutter: 20, attributions: layerModel.attributions, }), diff --git a/packages/openlayers/lib/map/index.ts b/packages/openlayers/lib/map/index.ts index 69fd672..c09ab91 100644 --- a/packages/openlayers/lib/map/index.ts +++ b/packages/openlayers/lib/map/index.ts @@ -1,3 +1,4 @@ export * from "./styles"; export { createMapFromContext, resetMapFromContext } from "./create-map"; export { applyContextDiffToMap } from "./apply-context-diff"; +export { listen } from "./register-events"; diff --git a/packages/openlayers/lib/map/register-events.test.ts b/packages/openlayers/lib/map/register-events.test.ts new file mode 100644 index 0000000..e97fe41 --- /dev/null +++ b/packages/openlayers/lib/map/register-events.test.ts @@ -0,0 +1,196 @@ +import Map from "ol/Map"; +import { Mock } from "vitest"; +import { + getFeaturesFromVectorSources, + getFeaturesFromWmsSources, + getGFIUrl, + listen, +} from "./register-events"; +import { Collection, MapBrowserEvent, Object as BaseObject } from "ol"; +import View from "ol/View"; +import { toLonLat } from "ol/proj"; +import TileWMS from "ol/source/TileWMS"; +import VectorSource from "ol/source/Vector"; +import VectorLayer from "ol/layer/Vector"; +import Point from "ol/geom/Point"; +import TileLayer from "ol/layer/Tile"; +import OlFeature from "ol/Feature"; + +const gfiResult = { + type: "Feature", + properties: { + density: 123, + }, + geometry: null, +}; +function createWmsSource() { + return new TileWMS({ + url: "http://my.service.org/wms?SERVICE=WMS", + params: { + LAYERS: "layerName", + FORMAT: "image/png", + TRANSPARENT: true, + }, + }); +} +function createMap(): Map { + const wmsLayer = new TileLayer({ + source: createWmsSource(), + }); + const feature = new OlFeature({ + geometry: new Point([100, 200]), + }); + const vectorLayer = new VectorLayer({ + source: new VectorSource({ + features: [feature], + }), + }); + const view = new View({ + projection: "EPSG:3857", + resolution: 1, + center: [0, 0], + }); + const map = new BaseObject() as Map; + Object.defineProperties(map, { + getView: { value: vi.fn(() => view) }, + getLayers: { value: vi.fn(() => new Collection([wmsLayer, vectorLayer])) }, + getEventPixel: { value: vi.fn(() => [10, 10]) }, + getCoordinateFromPixel: { value: vi.fn(() => [123, 123]) }, + getFeaturesAtPixel: { value: vi.fn(() => [feature]) }, + }); + return map; +} +function createMapEvent(map: Map, type: string) { + return new MapBrowserEvent( + type, + map, + new MouseEvent(type, { + clientX: 10, + clientY: 10, + }), + false, + ); +} + +describe("event registration", () => { + let map: Map; + beforeEach(() => { + map = createMap(); + vi.spyOn(global, "fetch").mockImplementation(() => + Promise.resolve({ + ok: true, + json: () => Promise.resolve({ features: [gfiResult] }), + } as Response), + ); + vi.useFakeTimers(); + }); + describe("getFeaturesFromVectorSources", () => { + it("returns an array of features", () => { + const features = getFeaturesFromVectorSources(map, [0, 0]); + expect(features).toEqual([ + { + geometry: { + coordinates: [100, 200], + type: "Point", + }, + properties: null, + type: "Feature", + }, + ]); + }); + }); + describe("getGFIUrl", () => { + let url: string; + const coordinate = [-182932.49329334166, 6125319.813853541]; + beforeEach(() => { + const wmsSource = createWmsSource(); + url = getGFIUrl(wmsSource, map, coordinate) as string; + }); + it("returns true", () => { + expect(url).toEqual( + "http://my.service.org/wms?SERVICE=WMS&REQUEST=GetFeatureInfo&QUERY_LAYERS=layerName&SERVICE=WMS&VERSION=1.3.0&FORMAT=image%2Fpng&STYLES=&TRANSPARENT=true&LAYERS=layerName&INFO_FORMAT=application%2Fjson&I=176&J=31&WIDTH=256&HEIGHT=256&CRS=EPSG%3A3857&BBOX=-183143.11977128312%2C6125051.950547744%2C-182837.37165814242%2C6125357.698660884", + ); + }); + }); + describe("getFeaturesFromWmsSources", () => { + it("queries the WMS sources", async () => { + const features = await getFeaturesFromWmsSources(map, [0, 0]); + expect(features).toEqual([gfiResult]); + }); + }); + describe("features hover event", () => { + let callback: Mock; + beforeEach(async () => { + callback = vi.fn(); + listen(map, "features-hover", callback); + map.dispatchEvent(createMapEvent(map, "pointermove")); + await vi.runAllTimersAsync(); + }); + it("registers the event on the map", () => { + expect(callback).toHaveBeenCalledWith({ + type: "features-hover", + features: [ + { + geometry: { + coordinates: [100, 200], + type: "Point", + }, + properties: null, + type: "Feature", + }, + { + geometry: null, + properties: { + density: 123, + }, + type: "Feature", + }, + ], + target: expect.anything(), + }); + }); + }); + describe("features click event", () => { + let callback: Mock; + beforeEach(async () => { + callback = vi.fn(); + listen(map, "features-click", callback); + map.dispatchEvent(createMapEvent(map, "click")); + await vi.runAllTimersAsync(); + }); + it("registers the event on the map", () => { + expect(callback).toHaveBeenCalledWith({ + type: "features-click", + features: [ + { + geometry: { + coordinates: [100, 200], + type: "Point", + }, + properties: null, + type: "Feature", + }, + { + geometry: null, + properties: { + density: 123, + }, + type: "Feature", + }, + ], + target: expect.anything(), + }); + }); + }); + describe("map click event", () => { + let callback: Mock; + beforeEach(() => { + callback = vi.fn(); + listen(map, "map-click", callback); + map.dispatchEvent(createMapEvent(map, "click")); + }); + it("registers the event on the map", () => { + expect(callback).toHaveBeenCalledWith({ coordinate: toLonLat([10, 10]) }); + }); + }); +}); diff --git a/packages/openlayers/lib/map/register-events.ts b/packages/openlayers/lib/map/register-events.ts new file mode 100644 index 0000000..5045e6f --- /dev/null +++ b/packages/openlayers/lib/map/register-events.ts @@ -0,0 +1,156 @@ +import Map, { MapObjectEventTypes } from "ol/Map"; +import { + FeaturesClickEventType, + FeaturesHoverEventType, + MapClickEventType, + MapEvent, + MapEventType, +} from "@geospatial-sdk/core"; +import { toLonLat } from "ol/proj"; +import GeoJSON from "ol/format/GeoJSON"; +import OlFeature from "ol/Feature"; +import BaseEvent from "ol/events/Event"; +import { MapBrowserEvent } from "ol"; +import { Coordinate } from "ol/coordinate"; +import TileWMS from "ol/source/TileWMS"; +import ImageWMS from "ol/source/ImageWMS"; +import Layer from "ol/layer/Layer"; +import { Pixel } from "ol/pixel"; +import type { Feature, FeatureCollection } from "geojson"; +import throttle from "lodash.throttle"; + +const GEOJSON = new GeoJSON(); + +export function getFeaturesFromVectorSources( + olMap: Map, + pixel: Pixel, +): Feature[] { + const olFeatures = olMap.getFeaturesAtPixel(pixel); + const { features } = GEOJSON.writeFeaturesObject(olFeatures as OlFeature[]); + if (!features) { + return []; + } + return features; +} + +export function getGFIUrl( + source: TileWMS | ImageWMS, + map: Map, + coordinate: Coordinate, +): string | null { + const view = map.getView(); + const projection = view.getProjection(); + const resolution = view.getResolution() as number; + const params = { + ...source.getParams(), + INFO_FORMAT: "application/json", + }; + return ( + source.getFeatureInfoUrl(coordinate, resolution, projection, params) ?? null + ); +} + +export function getFeaturesFromWmsSources( + olMap: Map, + coordinate: Coordinate, +): Promise { + const wmsSources: (ImageWMS | TileWMS)[] = olMap + .getLayers() + .getArray() + .filter( + (layer): layer is Layer => + layer instanceof Layer && + (layer.getSource() instanceof TileWMS || + layer.getSource() instanceof ImageWMS), + ) + .map((layer) => layer.getSource()!); + + if (!wmsSources.length) { + return Promise.resolve([]); + } + + const gfiUrls = wmsSources.reduce((urls, source) => { + const gfiUrl = getGFIUrl(source, olMap, coordinate); + return gfiUrl ? [...urls, gfiUrl] : urls; + }, [] as string[]); + return Promise.all( + gfiUrls.map((url) => + fetch(url) + .then((response) => response.json()) + .then((collection: FeatureCollection) => collection.features), + ), + ).then((features) => features.flat()); +} + +const getFeaturesFromWmsSourcesThrottled = throttle( + getFeaturesFromWmsSources, + 250, +); + +async function readFeaturesAtPixel( + map: Map, + event: MapBrowserEvent, +) { + return [ + ...getFeaturesFromVectorSources(map, event.pixel), + ...(await getFeaturesFromWmsSourcesThrottled(map, event.coordinate)), + ]; +} + +function registerFeatureClickEvent(map: Map) { + if (map.get(FeaturesClickEventType)) return; + map.on("click", async (event) => { + const features = await readFeaturesAtPixel(map, event); + map.dispatchEvent({ + type: FeaturesClickEventType, + features, + } as unknown as BaseEvent); + }); + map.set(FeaturesClickEventType, true); +} + +function registerFeatureHoverEvent(map: Map) { + if (map.get(FeaturesHoverEventType)) return; + map.on("pointermove", async (event) => { + const features = await readFeaturesAtPixel(map, event); + map.dispatchEvent({ + type: FeaturesHoverEventType, + features, + } as unknown as BaseEvent); + }); + map.set(FeaturesHoverEventType, true); +} + +export function listen( + map: Map, + event: MapEventType, + callback: (event: MapEvent) => void, +) { + switch (event) { + case FeaturesClickEventType: + registerFeatureClickEvent(map); + // we're using a custom event type here so we need to cast to unknown first + map.on(event as unknown as MapObjectEventTypes, (event) => { + callback(event as unknown as MapEvent); + }); + break; + case FeaturesHoverEventType: + registerFeatureHoverEvent(map); + // see comment above + map.on(event as unknown as MapObjectEventTypes, (event) => { + callback(event as unknown as MapEvent); + }); + break; + case MapClickEventType: + map.on("click", (event) => { + const coordinate = toLonLat( + event.pixel, + map.getView().getProjection(), + ) as [number, number]; + callback({ coordinate }); + }); + break; + default: + throw new Error(`Unrecognized event type: ${event}`); + } +} diff --git a/packages/openlayers/package.json b/packages/openlayers/package.json index d1fbc51..ca90cc4 100644 --- a/packages/openlayers/package.json +++ b/packages/openlayers/package.json @@ -29,6 +29,7 @@ }, "devDependencies": { "@types/chroma-js": "^2.4.3", + "@types/lodash.throttle": "^4.1.9", "ol": "^8.2.0", "ol-mapbox-style": "^12.3.5" }, @@ -37,7 +38,8 @@ }, "dependencies": { "@geospatial-sdk/core": "^0.0.5-alpha.2", - "chroma-js": "^2.4.2" + "chroma-js": "^2.4.2", + "lodash.throttle": "^4.1.1" }, "gitHead": "99dbb945a303b96e576a02a02bc0590785456bd3" }