Skip to content

Commit 1af6fd5

Browse files
committed
feat: add legend
1 parent 2013673 commit 1af6fd5

3 files changed

Lines changed: 17 additions & 5 deletions

File tree

src/App.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function App() {
1717
const initMap = async () => {
1818
console.log('initMap');
1919

20-
const { esriConfig, MapView, WebMap } = await getModules();
20+
const { esriConfig, MapView, WebMap, Legend } = await getModules();
2121

2222
esriConfig.portalUrl = 'https://maps.publiclands.utah.gov/portal';
2323

@@ -33,9 +33,15 @@ function App() {
3333
popup: null
3434
});
3535

36+
const legend = new Legend({
37+
view,
38+
container: document.createElement('div')
39+
});
40+
view.ui.add(legend, { position: 'bottom-right' });
41+
3642
await view.when();
3743

38-
featureLayer.current = view.map.layers.find(layer => layer.title === 'RS2477_Centerline_Secure - RS2477 Centerline');
44+
featureLayer.current = view.map.layers.find(layer => layer.title === 'RS2477 Centerlines');
3945
const layerView = await view.whenLayerView(featureLayer.current);
4046

4147
const table = view.map.tables[0];

src/App.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@ html, body, #root, .app {
1414
}
1515
.esri-view {
1616
flex: 1;
17+
.esri-widget {
18+
background-color: #ffffffb0;
19+
}
1720
}
1821
}

src/esriModules.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export default async () => {
88
'esri/views/MapView',
99
'esri/widgets/Feature',
1010
'esri/tasks/QueryTask',
11-
'esri/Graphic'
11+
'esri/Graphic',
12+
'esri/widgets/Legend'
1213
];
1314

1415
const [
@@ -17,7 +18,8 @@ export default async () => {
1718
MapView,
1819
Feature,
1920
QueryTask,
20-
Graphic
21+
Graphic,
22+
Legend
2123
] = await loadModules(requires, { version: '4.16', css: true });
2224

2325
return {
@@ -26,6 +28,7 @@ export default async () => {
2628
MapView,
2729
Feature,
2830
QueryTask,
29-
Graphic
31+
Graphic,
32+
Legend
3033
};
3134
}

0 commit comments

Comments
 (0)