Skip to content

Commit

Permalink
feat: implement layer selector
Browse files Browse the repository at this point in the history
waiting on new release of @ugrc/layer-selector

Closes #63
Closes #64
  • Loading branch information
stdavis committed Aug 24, 2022
1 parent 449c39b commit fce296d
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 1 deletion.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_DISCOVER=chance-source-liquid-nelson
1 change: 1 addition & 0 deletions .env.stage
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_DISCOVER=opera-event-little-pinball
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"sherlock",
"softprops",
"tanstack",
"TSQL"
"TSQL",
"ugrc"
],
"cSpell.language": "en,es-ES"
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"@fortawesome/free-solid-svg-icons": "^6.1.2",
"@fortawesome/react-fontawesome": "^0.2.0",
"@tanstack/react-query": "^4.2.1",
"@ugrc/layer-selector": "^6.1.0",
"bootstrap": "^5.2.0",
"clsx": "^1.2.1",
"downshift": "^6.1.9",
Expand Down
11 changes: 11 additions & 0 deletions public/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,17 @@
}
}
},
"layerSelector": {
"baseLayers": ["Lite", "Terrain", "Imagery"],
"overlays": [
{
"id": "Cities",
"Factory": "FeatureLayer",
"url": "https://gis.wfrc.org/arcgis/rest/services/General/ZoomToPlaceNames/FeatureServer/2",
"opacity": 1
}
]
},
"openOnLoad": {
"filter": true,
"projectInfo": true
Expand Down
69 changes: 69 additions & 0 deletions public/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"required": [
"appTitle",
"filter",
"layerSelector",
"openOnLoad",
"outFields",
"projectInformation",
Expand Down Expand Up @@ -304,6 +305,74 @@
}
}
},
"layerSelector": {
"description": "Configuration options for the base map selector widget",
"type": "object",
"additionalProperties": false,
"properties": {
"baseLayers": {
"type": "array",
"items": {
"anyOf": [
{
"type": "string"
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"id": {
"description": "The name of the layer",
"type": "string"
},
"Factory": {
"description": "The name of the esrijs module associated with the layer type",
"type": "string"
},
"urlTemplate": {
"description": "The urlTemplate for the layer. \"{quadWord}\" will be automatically replaced with the appropriate value at runtime.",
"type": "string"
}
},
"required": ["id", "Factory", "urlTemplate"]
}
]
}
},
"overlays": {
"type": "array",
"items": {
"anyOf": [
{
"type": "string"
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"id": {
"description": "The name of the layer",
"type": "string"
},
"Factory": {
"description": "The name of the esrijs module associated with the layer type",
"type": "string"
},
"url": {
"description": "The url for the layer",
"type": "string"
},
"opacity": {
"type": "number"
}
},
"required": ["id", "Factory", "url"]
}
]
}
}
}
},
"openOnLoad": {
"title": "Open On Load",
"description": "Controls whether specific map widgets default to be open on page load",
Expand Down
12 changes: 12 additions & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import WebMap from '@arcgis/core/WebMap';
import Home from '@arcgis/core/widgets/Home';
import { faFilter, faHandPointer } from '@fortawesome/free-solid-svg-icons';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import LayerSelector from '@ugrc/layer-selector';
import { useCallback, useEffect, useState } from 'react';
import 'typeface-montserrat';
import './App.scss';
Expand All @@ -24,9 +25,11 @@ const queryClient = new QueryClient();
function App() {
const [mapView, setMapView] = useState(null);
const [zoomToGraphic, setZoomToGraphic] = useState(null);
const [layerSelectorOptions, setLayerSelectorOptions] = useState(null);

const t = useSpecialTranslation();

// init map
useEffect(() => {
const map = new WebMap({
portalItem: { id: config.webMapId },
Expand All @@ -35,6 +38,14 @@ function App() {
view.popup = null;
view.ui.add(new Home({ view }), 'top-left');

setLayerSelectorOptions({
view,
quadWord: import.meta.env.VITE_DISCOVER,
position: 'top-left',
showOpacitySlider: true,
...config.layerSelector,
});

setMapView(view);
}, []);

Expand Down Expand Up @@ -194,6 +205,7 @@ function App() {
</MapWidget>
</MapWidgetContainer>
<Sherlock {...sherlockConfig}></Sherlock>
{layerSelectorOptions && <LayerSelector {...layerSelectorOptions} />}
</div>
</div>
<SplashScreen />
Expand Down
1 change: 1 addition & 0 deletions src/App.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@import 'bootstrap';

@import './variables.scss';
@import '../node_modules/@ugrc/layer-selector/src/LayerSelector.css';

.title {
font-family: Montserrat, Arial, sans-serif;
Expand Down

0 comments on commit fce296d

Please sign in to comment.