View on GitHub Sample viewer app

Identify a graphic to get further information about the object.

Image of identify graphics

Use case

A user may wish to select a graphic on a map to view relevant information about it.

How to use the sample

Select a graphic to identify it. You will see an alert message displayed.

How it works

  1. Use the .setOnMouseClicked() method to listen to clicks on a MapView.
  2. When the map view is clicked, use the event to create a Point from the location clicked on the map.
  3. Identify the graphic on the map view with MapView.identifyGraphicsOverlayAsync(graphicsOverlay, pointClicked, tolerance, max results).

Relevant API

  • Graphic
  • GraphicsOverlay
  • MapView
  • Point

Tags

graphics, identify

Sample Code

module-info.java module-info.java IdentifyGraphicsSample.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_graphics {
// 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;
requires javafx.controls;
exports com.esri.samples.identify_graphics;
}