Highlight SceneLayer

This sample shows how to highlight features in a SceneLayer representing campus buildings. When the SceneLayerView finished updating we loop through all the loaded features and put them in a list. An event listener is added on each list item which zooms to the 3D extent of the feature and highlights it.

To highlight a feature, call the highlight method of the feature's corresponding layerView with the feature or its objectID as parameter.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// add event listener on each list item
li.addEventListener("click", (event) => {
  const target = event.target;
  // get objectId of the feature that we previously stored as a data attribute
  const objectId = parseInt(target.getAttribute("data-object-id"));
  // create an extent query on the layer view that will return the 3D extent of the feature
  const queryExtent = new Query({
    objectIds: [objectId]
  });
  campusLayerView.queryExtent(queryExtent).then((result) => {
    // zoom to the extent of the feature; we use the expand method as we don't want to zoom very close to it
    view.goTo(result.extent.expand(4), { speedFactor: 0.5 });
  });
  // if any, remove the previous highlights
  if (highlight) {
    highlight.remove();
  }
  // highlight the feature with the returned objectId
  highlight = campusLayerView.highlight([objectId]);
});
Image preview of related sample SceneView - visibleArea

SceneView - visibleArea

SceneView - visibleArea()

Image preview of related sample FeatureLayerView - query statistics by geometry

FeatureLayerView - query statistics by geometry

FeatureLayerView - query statistics by geometry

Image preview of related sample Query features from a FeatureLayerView

Query features from a FeatureLayerView

Query features from a FeatureLayerView

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.

The developer dashboard has moved

You can no longer sign into this site. Go to your ArcGIS portal or the ArcGIS Location Platform dashboard to perform management tasks.

Your ArcGIS portal

Create, manage, and access API keys and OAuth 2.0 developer credentials, hosted layers, and data services.

Your ArcGIS Location Platform dashboard

Manage billing, monitor service usage, and access additional resources.

Learn more about these changes in the What's new in Esri Developers June 2024 blog post.

Close