1
2
3
4
5
6
7
8
9
featureLayer.watch("loaded", () => {
watchUtils.whenFalse(view, "updating", () => {
// Get the new extent of view/map whenever map is updated.if (view.extent) {
// Filter and show only the visible features in the feature table featureTable.filterGeometry = view.extent;
}
});
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// fires when "Zoom to selected feature(s)" button is clickedfunctionzoomToSelectedFeature() {
// Create a query off of the feature layerconst query = featureLayer.createQuery();
// Iterate through the features and grab the feature's objectIDconst featureIds = features.map((result) => {
return result.feature.getAttribute(featureLayer.objectIdField);
});
// Set the query's objectId query.objectIds = featureIds;
// Make sure to return the geometry to zoom to query.returnGeometry = true;
// Call queryFeatures on the feature layer and zoom to the resulting features featureLayer.queryFeatures(query).then((results) => {
view.goTo(results.features).catch((error) => {
if (error.name != "AbortError"){
console.error(error);
}
});
});
}
...