Skip to content

Commit

Permalink
feat: wire up lake and stream map controls
Browse files Browse the repository at this point in the history
  • Loading branch information
stdavis committed Oct 22, 2024
1 parent d3475f8 commit 31661a6
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 16 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@heroicons/react": "^2.1.5",
"@tanstack/react-query": "^5.56.2",
"@ugrc/layer-selector": "^6.2.8",
"@ugrc/utah-design-system": "^1.11.1",
"@ugrc/utah-design-system": "^1.11.2",
"firebase": "^10.13.1",
"immer": "^10.1.1",
"ky": "^1.7.2",
Expand Down
46 changes: 35 additions & 11 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import esriConfig from '@arcgis/core/config';
import Graphic from '@arcgis/core/Graphic';
import Viewpoint from '@arcgis/core/Viewpoint.js';
import {
Drawer,
Footer,
Header,
Sherlock,
UtahIdLogin,
masqueradeProvider,
featureServiceProvider,
useFirebaseAnalytics,
useFirebaseApp,
useFirebaseAuth,
Expand Down Expand Up @@ -48,8 +47,6 @@ const links = [
action: { url: 'https://gis.utah.gov/' },
},
];
const url = 'https://masquerade.ugrc.utah.gov/arcgis/rest/services/UtahLocator/GeocodeServer';
const wkid = 26912;

export default function App() {
const app = useFirebaseApp();
Expand Down Expand Up @@ -101,14 +98,42 @@ export default function App() {
// private
logEvent('sherlock:zoom');

zoom(new Viewpoint({ scale: 10000, targetGeometry: graphics[0].geometry }));
zoom(graphics[0].geometry);
placeGraphic(graphics);
};

const masqueradeSherlockOptions = {
provider: masqueradeProvider(url, wkid),
const { currentUser } = useFirebaseAuth();
const kyOptions = {
hooks: {
beforeRequest: [
async (request: Request) => {
console.log('interceptor ky options triggered');
request.headers.set('Authorization', `Bearer ${await currentUser?.getIdToken()}`);
},
],
},
};
const streamsSherlockOptions = {
provider: featureServiceProvider(
config.urls.streams,
config.fieldNames.WaterName,
// @ts-expect-error the type for this may be incorrect
config.fieldNames.COUNTY,
kyOptions,
),
maxResultsToDisplay: 10,
onSherlockMatch: onSherlockMatch,
onSherlockMatch,
};
const lakesSherlockOptions = {
provider: featureServiceProvider(
config.urls.lakes,
config.fieldNames.WaterName,
// @ts-expect-error the type for this may be incorrect
config.fieldNames.COUNTY,
kyOptions,
),
maxResultsToDisplay: 10,
onSherlockMatch,
};

// const onClick = useCallback(
Expand All @@ -123,7 +148,6 @@ export default function App() {
// },
// [mapView, trayState],
// );
const { currentUser } = useFirebaseAuth();
useEffect(() => {
if (currentUser) {
// this should take care of all requests made through the esri js api
Expand Down Expand Up @@ -162,12 +186,12 @@ export default function App() {
<h2 className="text-xl font-bold">Map controls</h2>
<div className="flex flex-col gap-4 rounded border border-zinc-200 p-3 dark:border-zinc-700">
<ErrorBoundary FallbackComponent={ErrorFallback}>
<Sherlock {...masqueradeSherlockOptions} label="Find a stream" />
<Sherlock {...streamsSherlockOptions} label="Find a stream" />
</ErrorBoundary>
</div>
<div className="flex flex-col gap-4 rounded border border-zinc-200 p-3 dark:border-zinc-700">
<ErrorBoundary FallbackComponent={ErrorFallback}>
<Sherlock {...masqueradeSherlockOptions} label="Find a lake" />
<Sherlock {...lakesSherlockOptions} label="Find a lake" />
</ErrorBoundary>
</div>
</div>
Expand Down

0 comments on commit 31661a6

Please sign in to comment.