0

I would like to ask that is there any method of features in ArcGIS can help me to show the current district that show on the map?

enter image description here

Like the picture above, ArcGIS have any features that can list down the districts that is currently on this map, For example, it able to list down: Kuala Lumpur, Shah Alam, PutraJaya, etc. And does not show out the district that currently doesn't appear on this view.

kiku
  • 147
  • 1
  • 10

1 Answers1

1

You can query the layer that contains the districts with the view extent.

If the district are in a FeatureLayer on your map, then you just need to query the layer view, all your features are already local because you are actually seen it. Take a look at this example, it does exactly that to display some information of the features in a list ArcGIS JS Examples - FeatureLayerView query. In the example, here is how he does the query,

layerView.queryFeatures({
    geometry: view.extent,
    returnGeometry: true,
    orderByFields: ["GEOID"]
})
.then(function (results) {
    graphics = results.features; // <- here are the features
    ...
})
.catch(function (error) {
    console.error("query failed: ", error);
});

Now if you don't have a FeatureLayer on the map with the districts, you will have to do a query to the service that contains that information. For this you can use QueryTask ArcGIS JS API - QueryTask.

cabesuon
  • 4,860
  • 2
  • 15
  • 24