Skip to content

Commit b669974

Browse files
authored
New Basemaps: Feature Layers Category (#601)
* Change feature layer renderer * Display subtype feature layer * Feature collection layer * Feature collection layer from portal - basemap updates * Feature collection layer from portal - fix indentations * Feature collection layer query * Feature layer definition expression * Feature layer dictionary renderer * Feature layer feature service * Feature layer geodatabase * Feature layer geopackage * Feature layer query * Feature layer selection * Feature layer shapefile * Service feature table cache * Service feature table manual cache * Service feature table no cache * Statistical query * Time based query * Display Subtype Feature Layer - update commenting * Service feature table manual cache - reordering * update build.gradle - versions * change feature layer renderer - set viewpoint on map view * Tidy up comment consistencies * Feature layer feature service - set viewpoint on map view * feature layer selection - set viewpoint on map view * service feature table cache - set viewpoint on map view * Tidy up comments
1 parent 7da2819 commit b669974

File tree

36 files changed

+316
-231
lines changed

36 files changed

+316
-231
lines changed

feature_layers/change-feature-layer-renderer/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
group = 'com.esri.samples'
77

88
ext {
9-
arcgisVersion = '100.9.0'
9+
arcgisVersion = '100.10.0-2992'
1010
}
1111
javafx {
1212
version = "11.0.2"

feature_layers/change-feature-layer-renderer/src/main/java/com/esri/samples/change_feature_layer_renderer/ChangeFeatureLayerRendererSample.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@
2525
import javafx.scene.layout.StackPane;
2626
import javafx.stage.Stage;
2727

28+
import com.esri.arcgisruntime.ArcGISRuntimeEnvironment;
2829
import com.esri.arcgisruntime.data.ServiceFeatureTable;
2930
import com.esri.arcgisruntime.geometry.Envelope;
3031
import com.esri.arcgisruntime.geometry.Point;
3132
import com.esri.arcgisruntime.layers.FeatureLayer;
3233
import com.esri.arcgisruntime.loadable.LoadStatus;
3334
import com.esri.arcgisruntime.mapping.ArcGISMap;
34-
import com.esri.arcgisruntime.mapping.Basemap;
35+
import com.esri.arcgisruntime.mapping.BasemapStyle;
3536
import com.esri.arcgisruntime.mapping.Viewpoint;
3637
import com.esri.arcgisruntime.mapping.view.MapView;
3738
import com.esri.arcgisruntime.symbology.SimpleMarkerSymbol;
@@ -61,6 +62,10 @@ public void start(Stage stage) {
6162
stage.setScene(scene);
6263
stage.show();
6364

65+
// authentication with an API key or named user is required to access basemaps and other location services
66+
String yourAPIKey = System.getProperty("apiKey");
67+
ArcGISRuntimeEnvironment.setApiKey(yourAPIKey);
68+
6469
// create a marker symbol renderer with a blue circle
6570
SimpleMarkerSymbol markerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, 0xFF0000FF, 5 );
6671
SimpleRenderer blueRenderer = new SimpleRenderer(markerSymbol);
@@ -81,16 +86,17 @@ public void start(Stage stage) {
8186
}
8287
});
8388

84-
// create a ArcGISMap with basemap topographic
85-
final ArcGISMap map = new ArcGISMap(Basemap.createTopographic());
89+
// create a map with the topographic basemap style
90+
final ArcGISMap map = new ArcGISMap(BasemapStyle.ARCGIS_TOPOGRAPHIC);
91+
92+
// create a map view and set the map to it
93+
mapView = new MapView();
94+
mapView.setMap(map);
8695

87-
// create starting envelope for the ArcGISMap
96+
// set a viewpoint on the map view
8897
Point topLeftPoint = new Point(-9177811, 4247000);
8998
Point bottomRightPoint = new Point(-9176791, 4247784);
90-
Envelope envelope = new Envelope(topLeftPoint, bottomRightPoint);
91-
92-
// set starting envelope for the ArcGISMap
93-
map.setInitialViewpoint(new Viewpoint(envelope));
99+
mapView.setViewpoint(new Viewpoint(new Envelope(topLeftPoint, bottomRightPoint)));
94100

95101
// create a service feature table using the url
96102
final ServiceFeatureTable featureTable = new ServiceFeatureTable(FEATURE_SERVICE_URL);
@@ -109,10 +115,6 @@ public void start(Stage stage) {
109115
}
110116
});
111117

112-
// create a view for the ArcGISMap and set ArcGISMap to it
113-
mapView = new MapView();
114-
mapView.setMap(map);
115-
116118
// add the map view and control panel to stack pane
117119
stackPane.getChildren().addAll(mapView, rendererSwitch);
118120
StackPane.setAlignment(rendererSwitch, Pos.TOP_LEFT);

feature_layers/display-subtype-feature-layer/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
group = 'com.esri.samples'
77

88
ext {
9-
arcgisVersion = '100.9.0'
9+
arcgisVersion = '100.10.0-2992'
1010
}
1111

1212
javafx {

feature_layers/display-subtype-feature-layer/src/main/java/com/esri/samples/display_subtype_feature_layer/DisplaySubtypeFeatureLayerController.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,28 @@
1717

1818
import java.nio.charset.StandardCharsets;
1919

20+
import javafx.fxml.FXML;
21+
import javafx.scene.control.CheckBox;
22+
import javafx.scene.control.Label;
23+
import javafx.scene.layout.VBox;
24+
import org.apache.commons.io.IOUtils;
25+
26+
import com.esri.arcgisruntime.ArcGISRuntimeEnvironment;
2027
import com.esri.arcgisruntime.arcgisservices.LabelDefinition;
2128
import com.esri.arcgisruntime.data.ServiceFeatureTable;
2229
import com.esri.arcgisruntime.geometry.Envelope;
2330
import com.esri.arcgisruntime.geometry.SpatialReferences;
2431
import com.esri.arcgisruntime.layers.SubtypeFeatureLayer;
2532
import com.esri.arcgisruntime.layers.SubtypeSublayer;
2633
import com.esri.arcgisruntime.mapping.ArcGISMap;
27-
import com.esri.arcgisruntime.mapping.Basemap;
34+
import com.esri.arcgisruntime.mapping.BasemapStyle;
2835
import com.esri.arcgisruntime.mapping.Viewpoint;
2936
import com.esri.arcgisruntime.mapping.view.MapView;
3037
import com.esri.arcgisruntime.symbology.Renderer;
3138
import com.esri.arcgisruntime.symbology.SimpleMarkerSymbol;
3239
import com.esri.arcgisruntime.symbology.SimpleRenderer;
3340
import com.esri.arcgisruntime.symbology.Symbol;
3441

35-
import javafx.fxml.FXML;
36-
import javafx.scene.control.CheckBox;
37-
import javafx.scene.control.Label;
38-
import javafx.scene.layout.VBox;
39-
import org.apache.commons.io.IOUtils;
40-
4142
public class DisplaySubtypeFeatureLayerController {
4243

4344
@FXML private MapView mapView;
@@ -53,19 +54,21 @@ public class DisplaySubtypeFeatureLayerController {
5354
public void initialize() {
5455

5556
try {
57+
// authentication with an API key or named user is required to access basemaps and other location services
58+
String yourAPIKey = System.getProperty("apiKey");
59+
ArcGISRuntimeEnvironment.setApiKey(yourAPIKey);
5660

57-
// create a map with streets night vector basemap and add it to the map view
58-
ArcGISMap map = new ArcGISMap();
59-
map.setBasemap(Basemap.createStreetsNightVector());
61+
// create a map with the streets night basemap style and add it to the map view
62+
ArcGISMap map = new ArcGISMap(BasemapStyle.ARCGIS_STREETS_NIGHT);
6063
mapView.setMap(map);
6164
// display the current map scale
6265
mapView.addMapScaleChangedListener(mapScaleChangedEvent ->
6366
currentMapScaleLabel.setText("Current map scale: 1:" + Math.round(mapView.getMapScale())));
6467

65-
// set the viewpoint to Naperville, Illinois
68+
// set a viewpoint on the map view, to Naperville, Illinois
6669
Viewpoint initialViewpoint = new Viewpoint(new Envelope(-9812691.11079696, 5128687.20710657,
6770
-9812377.9447607, 5128865.36767282, SpatialReferences.getWebMercator()));
68-
map.setInitialViewpoint(initialViewpoint);
71+
mapView.setViewpoint(initialViewpoint);
6972

7073
// create a subtype feature layer from the service feature table, and add it to the map
7174
ServiceFeatureTable serviceFeatureTable = new ServiceFeatureTable("https://sampleserver7.arcgisonline" +

feature_layers/feature-collection-layer-from-portal/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
group = 'com.esri.samples'
77

88
ext {
9-
arcgisVersion = '100.9.0'
9+
arcgisVersion = '100.10.0-2992'
1010
}
1111

1212
javafx {

feature_layers/feature-collection-layer-from-portal/src/main/java/com/esri/samples/feature_collection_layer_from_portal/FeatureCollectionLayerFromPortalSample.java

Lines changed: 105 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -26,129 +26,134 @@
2626
import javafx.scene.layout.StackPane;
2727
import javafx.stage.Stage;
2828

29+
import com.esri.arcgisruntime.ArcGISRuntimeEnvironment;
2930
import com.esri.arcgisruntime.data.FeatureCollection;
3031
import com.esri.arcgisruntime.layers.FeatureCollectionLayer;
3132
import com.esri.arcgisruntime.loadable.LoadStatus;
3233
import com.esri.arcgisruntime.mapping.ArcGISMap;
33-
import com.esri.arcgisruntime.mapping.Basemap;
34+
import com.esri.arcgisruntime.mapping.BasemapStyle;
3435
import com.esri.arcgisruntime.mapping.view.MapView;
3536
import com.esri.arcgisruntime.portal.Portal;
3637
import com.esri.arcgisruntime.portal.PortalItem;
3738

3839
public class FeatureCollectionLayerFromPortalSample extends Application {
3940

40-
private ArcGISMap map;
41-
private MapView mapView;
42-
private Portal portal;
43-
private TextField inputTextField;
44-
private PortalItem portalItem; // keep loadable in scope to avoid garbage collection
45-
46-
@Override
47-
public void start(Stage stage) {
48-
// set up the application scene
49-
try {
50-
// create stack pane and application scene
51-
StackPane stackPane = new StackPane();
52-
Scene scene = new Scene(stackPane);
53-
54-
// set title, size, and add scene to stage
55-
stage.setTitle("Feature Collection Layer From Portal");
56-
stage.setWidth(800);
57-
stage.setHeight(700);
58-
stage.setScene(scene);
59-
stage.show();
60-
61-
// create a new ArcGISMap with the oceans basemap
62-
map = new ArcGISMap(Basemap.createOceans());
63-
64-
// create a map view and set the map to it
65-
mapView = new MapView();
66-
mapView.setMap(map);
67-
68-
// create portal
69-
portal = new Portal("https://www.arcgis.com/");
70-
71-
// create text field to input user's own portal item ID
72-
inputTextField = new TextField("32798dfad17942858d5eef82ee802f0b");
73-
inputTextField.setMaxWidth(250);
74-
75-
// fetch the default feature collection layer from the portal
76-
fetchFeatureCollectionFromPortal();
77-
78-
// create button to perform action
79-
Button fetchFromPortalButton = new Button("Open from portal item");
80-
fetchFromPortalButton.setMaxWidth(250);
81-
82-
// verify the input and fetch the portal item
83-
fetchFromPortalButton.setOnAction(e -> fetchFeatureCollectionFromPortal());
84-
85-
// add the map view and control panel to stack pane
86-
stackPane.getChildren().addAll(mapView, inputTextField, fetchFromPortalButton);
87-
StackPane.setAlignment(inputTextField, Pos.TOP_LEFT);
88-
StackPane.setMargin(inputTextField, new Insets(10, 0, 0, 10));
89-
StackPane.setAlignment(fetchFromPortalButton, Pos.TOP_LEFT);
90-
StackPane.setMargin(fetchFromPortalButton, new Insets(40, 0, 0, 10));
91-
92-
} catch (Exception e) {
93-
// on any error, display the stack trace
94-
e.printStackTrace();
95-
}
41+
private ArcGISMap map;
42+
private MapView mapView;
43+
private Portal portal;
44+
private TextField inputTextField;
45+
private PortalItem portalItem; // keep loadable in scope to avoid garbage collection
46+
47+
@Override
48+
public void start(Stage stage) {
49+
// set up the application scene
50+
try {
51+
// create stack pane and application scene
52+
StackPane stackPane = new StackPane();
53+
Scene scene = new Scene(stackPane);
54+
55+
// set title, size, and add scene to stage
56+
stage.setTitle("Feature Collection Layer From Portal");
57+
stage.setWidth(800);
58+
stage.setHeight(700);
59+
stage.setScene(scene);
60+
stage.show();
61+
62+
// authentication with an API key or named user is required to access basemaps and other location services
63+
String yourAPIKey = System.getProperty("apiKey");
64+
ArcGISRuntimeEnvironment.setApiKey(yourAPIKey);
65+
66+
// create a map with the oceans basemap style
67+
map = new ArcGISMap(BasemapStyle.ARCGIS_OCEANS);
68+
69+
// create a map view and set the map to it
70+
mapView = new MapView();
71+
mapView.setMap(map);
72+
73+
// create portal
74+
portal = new Portal("https://www.arcgis.com/");
75+
76+
// create text field to input user's own portal item ID
77+
inputTextField = new TextField("32798dfad17942858d5eef82ee802f0b");
78+
inputTextField.setMaxWidth(250);
79+
80+
// fetch the default feature collection layer from the portal
81+
fetchFeatureCollectionFromPortal();
82+
83+
// create button to perform action
84+
Button fetchFromPortalButton = new Button("Open from portal item");
85+
fetchFromPortalButton.setMaxWidth(250);
86+
87+
// verify the input and fetch the portal item
88+
fetchFromPortalButton.setOnAction(e -> fetchFeatureCollectionFromPortal());
89+
90+
// add the map view and control panel to stack pane
91+
stackPane.getChildren().addAll(mapView, inputTextField, fetchFromPortalButton);
92+
StackPane.setAlignment(inputTextField, Pos.TOP_LEFT);
93+
StackPane.setMargin(inputTextField, new Insets(10, 0, 0, 10));
94+
StackPane.setAlignment(fetchFromPortalButton, Pos.TOP_LEFT);
95+
StackPane.setMargin(fetchFromPortalButton, new Insets(40, 0, 0, 10));
96+
97+
} catch (Exception e) {
98+
// on any error, display the stack trace
99+
e.printStackTrace();
96100
}
101+
}
97102

98-
/**
99-
* Fetch feature collection from portal and load as feature layer.
100-
*/
101-
private void fetchFeatureCollectionFromPortal() {
103+
/**
104+
* Fetch feature collection from portal and load as feature layer.
105+
*/
106+
private void fetchFeatureCollectionFromPortal() {
102107

103-
if (!inputTextField.getText().isEmpty()) {
104-
// crate portal item
105-
portalItem = new PortalItem(portal, inputTextField.getText());
106-
portalItem.loadAsync();
108+
if (!inputTextField.getText().isEmpty()) {
109+
// crate portal item
110+
portalItem = new PortalItem(portal, inputTextField.getText());
111+
portalItem.loadAsync();
107112

108-
portalItem.addDoneLoadingListener(() -> {
113+
portalItem.addDoneLoadingListener(() -> {
109114

110-
if (portalItem.getLoadStatus() == LoadStatus.LOADED) {
115+
if (portalItem.getLoadStatus() == LoadStatus.LOADED) {
111116

112-
if (portalItem.getType() == PortalItem.Type.FEATURE_COLLECTION) {
117+
if (portalItem.getType() == PortalItem.Type.FEATURE_COLLECTION) {
113118

114-
// create feature collection and add to the map as a layer
115-
FeatureCollection featureCollection = new FeatureCollection(portalItem);
116-
FeatureCollectionLayer featureCollectionLayer = new FeatureCollectionLayer(featureCollection);
119+
// create feature collection and add to the map as a layer
120+
FeatureCollection featureCollection = new FeatureCollection(portalItem);
121+
FeatureCollectionLayer featureCollectionLayer = new FeatureCollectionLayer(featureCollection);
117122

118-
// add feature collection layer to the map
119-
map.getOperationalLayers().clear();
120-
map.getOperationalLayers().add(featureCollectionLayer);
123+
// add feature collection layer to the map
124+
map.getOperationalLayers().clear();
125+
map.getOperationalLayers().add(featureCollectionLayer);
121126

122-
} else {
123-
new Alert(Alert.AlertType.ERROR, "Portal item is not a feature collection").show();
124-
}
125-
} else {
126-
new Alert(Alert.AlertType.ERROR, "Portal item failed to load").show();
127-
}
128-
});
127+
} else {
128+
new Alert(Alert.AlertType.ERROR, "Portal item is not a feature collection").show();
129+
}
129130
} else {
130-
new Alert(Alert.AlertType.ERROR, "Portal Item ID is empty").show();
131-
}
132-
133-
}
134-
/**
135-
* Stops and releases all resources used in application.
136-
*/
137-
@Override
138-
public void stop() {
139-
140-
if (mapView != null) {
141-
mapView.dispose();
131+
new Alert(Alert.AlertType.ERROR, "Portal item failed to load").show();
142132
}
133+
});
134+
} else {
135+
new Alert(Alert.AlertType.ERROR, "Portal Item ID is empty").show();
143136
}
144137

145-
/**
146-
* Opens and runs application.
147-
*
148-
* @param args arguments passed to this application
149-
*/
150-
public static void main(String[] args) {
138+
}
139+
/**
140+
* Stops and releases all resources used in application.
141+
*/
142+
@Override
143+
public void stop() {
151144

152-
Application.launch(args);
145+
if (mapView != null) {
146+
mapView.dispose();
153147
}
148+
}
149+
150+
/**
151+
* Opens and runs application.
152+
*
153+
* @param args arguments passed to this application
154+
*/
155+
public static void main(String[] args) {
156+
157+
Application.launch(args);
158+
}
154159
}

feature_layers/feature-collection-layer-query/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
group = 'com.esri.samples'
77

88
ext {
9-
arcgisVersion = '100.9.0'
9+
arcgisVersion = '100.10.0-2992'
1010
}
1111

1212
javafx {

0 commit comments

Comments
 (0)