mapView.setOnMouseClicked(event -> {
// check for primary or secondary mouse click
if (event.isStillSincePress() && event.getButton() == MouseButton.PRIMARY) {
// create a point from where the user clicked
Point2D point = new Point2D(event.getX(), event.getY());
// identify the clicked features
final ListenableFuture<List<IdentifyLayerResult>> results = mapView.identifyLayersAsync(point, 10,
false, 10);
results.addDoneListener(() -> {
// System.out.println("Listener");
try {
List<IdentifyLayerResult> ListLayer = results.get();
int j = 0;
for (IdentifyLayerResult layer : ListLayer) {
// search the layers for identified features
List<Feature> features = layer.getElements().stream()
.filter(geoElement -> geoElement instanceof Feature).map(g -> (Feature) g)
.collect(Collectors.toList());
// select features
int FeaturesSize = features.size();
for (int i = 0; i < FeaturesSize; i++) {
Feature f = features.get(i);
// printFeature_Info(f);
String attributeNamePopUp = "";
try {
attributeNamePopUp = layer.getLayerContent().getName();
} catch (java.lang.NullPointerException e) {
}
new ArcGIS_Information_Frame_For_Layer(f.getAttributes(), attributeNamePopUp);
setupGraphicsOverlay();
List<Graphic> graphics = new ArrayList<>();
graphics.add(new Graphic(f.getGeometry()));
graphicsOverlay.getGraphics().addAll(graphics);
}
}
} catch (Exception e) {
e.printStackTrace();
}
});
}
});