From 05430089a2da24fab35c9b369e98e0fe406a4baf Mon Sep 17 00:00:00 2001 From: stdavis Date: Thu, 15 Dec 2022 16:33:39 -0700 Subject: [PATCH] feat!: add support for black and white imagery base map BREAKING CHANGE: Added the following config props under `layerSelector`: - `BWName` - `BWOpacity` Closes #110 --- .vscode/settings.json | 3 +- ...perties-layerselector-properties-bwname.md | 3 ++ ...ties-layerselector-properties-bwopacity.md | 3 ++ docs/config-properties-layerselector.md | 48 +++++++++++++++++-- public/config.json | 6 ++- public/config.schema.json | 9 ++++ src/App.jsx | 16 +++++++ 7 files changed, 80 insertions(+), 8 deletions(-) create mode 100644 docs/config-properties-layerselector-properties-bwname.md create mode 100644 docs/config-properties-layerselector-properties-bwopacity.md diff --git a/.vscode/settings.json b/.vscode/settings.json index 1ea1b25..6c2bab9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -23,7 +23,8 @@ "tanstack", "TSQL", "udot", - "ugrc" + "ugrc", + "utah" ], "cSpell.language": "en,es-ES", "editor.defaultFormatter": "esbenp.prettier-vscode" diff --git a/docs/config-properties-layerselector-properties-bwname.md b/docs/config-properties-layerselector-properties-bwname.md new file mode 100644 index 0000000..e4c9462 --- /dev/null +++ b/docs/config-properties-layerselector-properties-bwname.md @@ -0,0 +1,3 @@ +## BWName Type + +`string` diff --git a/docs/config-properties-layerselector-properties-bwopacity.md b/docs/config-properties-layerselector-properties-bwopacity.md new file mode 100644 index 0000000..9a9521c --- /dev/null +++ b/docs/config-properties-layerselector-properties-bwopacity.md @@ -0,0 +1,3 @@ +## BWOpacity Type + +`string` diff --git a/docs/config-properties-layerselector.md b/docs/config-properties-layerselector.md index fbd3999..5320563 100644 --- a/docs/config-properties-layerselector.md +++ b/docs/config-properties-layerselector.md @@ -4,14 +4,16 @@ # layerSelector Properties -| Property | Type | Required | Nullable | Defined by | -| :------------------------ | :------ | :------- | :------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [baseLayers](#baselayers) | `array` | Optional | cannot be null | [WFRC RTP Projects Application Configuration](config-properties-layerselector-properties-baselayers.md "https://wfrc.org/??/config.schema.json#/properties/layerSelector/properties/baseLayers") | -| [overlays](#overlays) | `array` | Optional | cannot be null | [WFRC RTP Projects Application Configuration](config-properties-layerselector-properties-overlays.md "https://wfrc.org/??/config.schema.json#/properties/layerSelector/properties/overlays") | +| Property | Type | Required | Nullable | Defined by | +| :------------------------ | :------- | :------- | :------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [baseLayers](#baselayers) | `array` | Optional | cannot be null | [WFRC RTP Projects Application Configuration](config-properties-layerselector-properties-baselayers.md "https://wfrc.org/??/config.schema.json#/properties/layerSelector/properties/baseLayers") | +| [overlays](#overlays) | `array` | Optional | cannot be null | [WFRC RTP Projects Application Configuration](config-properties-layerselector-properties-overlays.md "https://wfrc.org/??/config.schema.json#/properties/layerSelector/properties/overlays") | +| [BWName](#bwname) | `string` | Optional | cannot be null | [WFRC RTP Projects Application Configuration](config-properties-layerselector-properties-bwname.md "https://wfrc.org/??/config.schema.json#/properties/layerSelector/properties/BWName") | +| [BWOpacity](#bwopacity) | `string` | Optional | cannot be null | [WFRC RTP Projects Application Configuration](config-properties-layerselector-properties-bwopacity.md "https://wfrc.org/??/config.schema.json#/properties/layerSelector/properties/BWOpacity") | ## baseLayers - +The base layers to be displayed in the widget. Use a string value that matches the `BWName` value to create a black and white imagery layer. `baseLayers` @@ -44,3 +46,39 @@ an array of merged types ([Details](config-properties-layerselector-properties-b ### overlays Type an array of merged types ([Details](config-properties-layerselector-properties-overlays-items.md)) + +## BWName + +The name of the black and white imagery layer token in the baseLayers array + +`BWName` + +* is optional + +* Type: `string` + +* cannot be null + +* defined in: [WFRC RTP Projects Application Configuration](config-properties-layerselector-properties-bwname.md "https://wfrc.org/??/config.schema.json#/properties/layerSelector/properties/BWName") + +### BWName Type + +`string` + +## BWOpacity + +The opacity of the black and white imagery layer expressed as a percentage (e.g. 75%) + +`BWOpacity` + +* is optional + +* Type: `string` + +* cannot be null + +* defined in: [WFRC RTP Projects Application Configuration](config-properties-layerselector-properties-bwopacity.md "https://wfrc.org/??/config.schema.json#/properties/layerSelector/properties/BWOpacity") + +### BWOpacity Type + +`string` diff --git a/public/config.json b/public/config.json index 5b0e28b..d6a9e7e 100644 --- a/public/config.json +++ b/public/config.json @@ -156,7 +156,7 @@ } }, "layerSelector": { - "baseLayers": ["Lite", "Terrain", "Hybrid"], + "baseLayers": ["Lite", "Terrain", "Hybrid", "B/W Imagery"], "overlays": [ { "id": "Cities", @@ -164,7 +164,9 @@ "url": "https://gis.wfrc.org/arcgis/rest/services/General/ZoomToPlaceNames/FeatureServer/2", "opacity": 1 } - ] + ], + "BWName": "B/W Imagery", + "BWOpacity": "75%" }, "openOnLoad": { "filter": true, diff --git a/public/config.schema.json b/public/config.schema.json index 224635b..7f52216 100644 --- a/public/config.schema.json +++ b/public/config.schema.json @@ -360,6 +360,7 @@ "additionalProperties": false, "properties": { "baseLayers": { + "description": "The base layers to be displayed in the widget. Use a string value that matches the `BWName` value to create a black and white imagery layer.", "type": "array", "items": { "anyOf": [ @@ -419,6 +420,14 @@ } ] } + }, + "BWName": { + "description": "The name of the black and white imagery layer token in the baseLayers array", + "type": "string" + }, + "BWOpacity": { + "description": "The opacity of the black and white imagery layer expressed as a percentage (e.g. 75%)", + "type": "string" } } }, diff --git a/src/App.jsx b/src/App.jsx index 3d3dfa1..678d343 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,6 +1,7 @@ import * as reactiveUtils from '@arcgis/core/core/reactiveUtils'; import { whenOnce } from '@arcgis/core/core/reactiveUtils'; import Graphic from '@arcgis/core/Graphic'; +import WebTileLayer from '@arcgis/core/layers/WebTileLayer'; import Viewpoint from '@arcgis/core/Viewpoint'; import MapView from '@arcgis/core/views/MapView'; import WebMap from '@arcgis/core/WebMap'; @@ -78,6 +79,21 @@ function App() { 'top-left' ); + config.layerSelector.baseLayers = config.layerSelector.baseLayers.map((layer) => { + if (typeof layer === 'string' && layer === config.layerSelector.BWName) { + return { + id: config.layerSelector.BWName, + Factory: WebTileLayer, + urlTemplate: `https://discover.agrc.utah.gov/login/path/${ + import.meta.env.VITE_DISCOVER + }/tiles/utah/{level}/{col}/{row}`, + effect: `grayscale(100%) opacity(${config.layerSelector.BWOpacity})`, + }; + } + + return layer; + }); + setLayerSelectorOptions({ view, quadWord: import.meta.env.VITE_DISCOVER,