|
17 | 17 | package com.esri.samples.wmts_layer;
|
18 | 18 |
|
19 | 19 | import java.util.List;
|
20 |
| -import javafx.application.Application; |
21 |
| -import javafx.scene.Scene; |
22 |
| -import javafx.scene.control.Alert; |
23 |
| -import javafx.scene.layout.StackPane; |
24 |
| -import javafx.stage.Stage; |
| 20 | +import java.util.stream.Collectors; |
25 | 21 |
|
26 | 22 | import com.esri.arcgisruntime.layers.WmtsLayer;
|
27 | 23 | import com.esri.arcgisruntime.loadable.LoadStatus;
|
|
31 | 27 | import com.esri.arcgisruntime.ogc.wmts.WmtsLayerInfo;
|
32 | 28 | import com.esri.arcgisruntime.ogc.wmts.WmtsService;
|
33 | 29 | import com.esri.arcgisruntime.ogc.wmts.WmtsServiceInfo;
|
| 30 | +import javafx.application.Application; |
| 31 | +import javafx.scene.Scene; |
| 32 | +import javafx.scene.control.Alert; |
| 33 | +import javafx.scene.layout.StackPane; |
| 34 | +import javafx.stage.Stage; |
34 | 35 |
|
35 | 36 | public class WmtsLayerSample extends Application {
|
36 | 37 |
|
@@ -58,15 +59,17 @@ public void start(Stage stage) {
|
58 | 59 | mapView.setMap(map);
|
59 | 60 |
|
60 | 61 | // create a WMTS service from a URL
|
61 |
| - String serviceURL = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer/WMTS"; |
| 62 | + String serviceURL = "https://gibs.earthdata.nasa.gov/wmts/epsg4326/best"; |
62 | 63 | wmtsService = new WmtsService(serviceURL);
|
63 | 64 | wmtsService.addDoneLoadingListener(() -> {
|
64 | 65 | if (wmtsService.getLoadStatus() == LoadStatus.LOADED) {
|
65 | 66 | WmtsServiceInfo wmtsServiceInfo = wmtsService.getServiceInfo();
|
66 |
| - // get the first layer's ID |
67 |
| - List<WmtsLayerInfo> layerInfos = wmtsServiceInfo.getLayerInfos(); |
| 67 | + // obtain the read only list of WMTS layer info objects, and select the one with the desired Id value. |
| 68 | + List<WmtsLayerInfo> wmtsLayerInfos = wmtsServiceInfo.getLayerInfos(); |
| 69 | + WmtsLayerInfo layerInfo = wmtsLayerInfos.stream() |
| 70 | + .filter(layer -> layer.getId().equals("SRTM_Color_Index")).collect(Collectors.toList()).get(0); |
68 | 71 | // create the WMTS layer with the LayerInfo
|
69 |
| - WmtsLayer wmtsLayer = new WmtsLayer(layerInfos.get(0)); |
| 72 | + WmtsLayer wmtsLayer = new WmtsLayer(layerInfo); |
70 | 73 | map.setBasemap(new Basemap(wmtsLayer));
|
71 | 74 | } else {
|
72 | 75 | Alert alert = new Alert(Alert.AlertType.ERROR, "Failed to load WMTS layer");
|
|
0 commit comments