Skip to content

Commit 3622adf

Browse files
committed
show progress indicator until layer is rendered
1 parent 74c2be1 commit 3622adf

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/main/java/com/esri/samples/featurelayers/list_releated_features/ListRelatedFeaturesSample.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import javafx.scene.control.Accordion;
2828
import javafx.scene.control.Alert;
2929
import javafx.scene.control.ListView;
30+
import javafx.scene.control.ProgressIndicator;
3031
import javafx.scene.control.TitledPane;
3132
import javafx.scene.input.MouseButton;
3233
import javafx.scene.layout.StackPane;
@@ -43,6 +44,7 @@
4344
import com.esri.arcgisruntime.geometry.Point;
4445
import com.esri.arcgisruntime.layers.FeatureLayer;
4546
import com.esri.arcgisruntime.mapping.ArcGISMap;
47+
import com.esri.arcgisruntime.mapping.view.DrawStatus;
4648
import com.esri.arcgisruntime.mapping.view.MapView;
4749

4850
public class ListRelatedFeaturesSample extends Application {
@@ -64,6 +66,11 @@ public void start(Stage stage) {
6466
stage.setScene(scene);
6567
stage.show();
6668

69+
// show a progress indicator while the map loads
70+
ProgressIndicator progressIndicator = new ProgressIndicator();
71+
progressIndicator.setProgress(ProgressIndicator.INDETERMINATE_PROGRESS);
72+
progressIndicator.setMaxSize(25, 25);
73+
6774
// create an accordion view for displaying the related features according to their feature table
6875
Accordion accordion = new Accordion();
6976
accordion.setMaxSize(200, 300);
@@ -75,6 +82,13 @@ public void start(Stage stage) {
7582
mapView = new MapView();
7683
mapView.setMap(map);
7784

85+
// hide the progress indicator when the layer is done drawing
86+
mapView.addDrawStatusChangedListener(drawStatusChangedEvent -> {
87+
if (drawStatusChangedEvent.getDrawStatus() == DrawStatus.COMPLETED) {
88+
progressIndicator.setVisible(false);
89+
}
90+
});
91+
7892
// wait until the map is done loading
7993
map.addDoneLoadingListener(() -> {
8094
// get the first feature layer for querying
@@ -152,9 +166,9 @@ public void start(Stage stage) {
152166
});
153167

154168
// add the map view and accordion view to stack pane
155-
stackPane.getChildren().addAll(mapView, accordion);
169+
stackPane.getChildren().addAll(mapView, accordion, progressIndicator);
156170
StackPane.setAlignment(accordion, Pos.TOP_LEFT);
157-
171+
StackPane.setAlignment(progressIndicator, Pos.CENTER);
158172
} catch (Exception e) {
159173
// on any error, display the stack trace.
160174
e.printStackTrace();

0 commit comments

Comments
 (0)