View on GitHub Sample viewer app

Identify features in all layers in a map.

Image of identify layers

Use case

Identify layers allows users to return features on a map at a specified location across multiple layers. Because some layer types have sublayers, the sample recursively counts results for sublayers within each layer.

How to use the sample

Click to identify features. An alert will show all layers with features under the clicked location, as well as the number of features.

How it works

  1. The clicked map point is passed to MapView.identifyLayersAsync
  2. For each IdentifyLayerResult in the results, features are counted.
    • Note: there is one identify result per layer with matching features; if the feature count is 0, that means a sublayer contains the matching features.

Relevant API

  • IdentifyLayerResult
  • MapView

Additional information

The GeoView supports two methods of identify: identifyLayerAsync(), which identifies features within a specific layer and identifyLayersAsync(), which identifies features for all layers in the current view.

Tags

identify, recursion, recursive, sublayers

Sample Code

module-info.java module-info.java IdentifyLayersSample.java
/*
* Copyright 2022 Esri.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module com.esri.samples.identify_layers {
// require ArcGIS Maps SDK for Java module
requires com.esri.arcgisruntime;
// handle SLF4J http://www.slf4j.org/codes.html#StaticLoggerBinder
requires org.slf4j.nop;
// require JavaFX modules that the application uses
requires javafx.graphics;
exports com.esri.samples.identify_layers;
}