Skip to content

Commit 25a16b5

Browse files
committed
show progress indicator while loading
1 parent dab7fe8 commit 25a16b5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/main/java/com/esri/samples/ogc/wms_layer_url/WmsLayerUrlSample.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@
2020
import java.util.List;
2121

2222
import javafx.application.Application;
23+
import javafx.geometry.Pos;
2324
import javafx.scene.Scene;
2425
import javafx.scene.control.Alert;
26+
import javafx.scene.control.ProgressIndicator;
2527
import javafx.scene.layout.StackPane;
2628
import javafx.stage.Stage;
2729

@@ -56,6 +58,10 @@ public void start(Stage stage) {
5658
mapView = new MapView();
5759
mapView.setMap(map);
5860

61+
ProgressIndicator progressIndicator = new ProgressIndicator();
62+
progressIndicator.setProgress(ProgressIndicator.INDETERMINATE_PROGRESS);
63+
progressIndicator.setMaxSize(25, 25);
64+
5965
// create a WMS layer
6066
List<String> wmsLayerNames = Collections.singletonList("0");
6167
String url = "https://certmapper.cr.usgs.gov/arcgis/services/geology/africa/MapServer/WMSServer?request=GetCapabilities&service=WMS";
@@ -69,11 +75,13 @@ public void start(Stage stage) {
6975
Alert alert = new Alert(Alert.AlertType.ERROR, "Failed to load WMS layer");
7076
alert.show();
7177
}
78+
progressIndicator.setVisible(false);
7279
});
7380
wmsLayer.loadAsync();
7481

7582
// add the map view to stack pane
76-
stackPane.getChildren().addAll(mapView);
83+
stackPane.getChildren().addAll(mapView, progressIndicator);
84+
StackPane.setAlignment(progressIndicator, Pos.CENTER);
7785
} catch (Exception e) {
7886
// on any error, display the stack trace.
7987
e.printStackTrace();

0 commit comments

Comments
 (0)