Skip to content

Commit 83ecf2b

Browse files
committed
merged master
2 parents a884216 + b264dfd commit 83ecf2b

File tree

12 files changed

+543
-3
lines changed

12 files changed

+543
-3
lines changed
380 KB
Loading

src/main/java/com/esri/samples/displayinformation/add_graphics_with_renderer/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<h1>Add Graphics with Renderer</h1>
22

33
<p>Demonstrates how to add graphics to a graphics overlay and display them with a renderer. A renderer allows you to
4-
change the style of all graphics in an overlay by only changing one copy of the symbol. A renderer will only change
5-
the symbol for graphics that do not specify their own symbol.</p>
4+
change the style of all graphics in an overlay by only changing one copy of the symbol. A renderer will only effect
5+
graphics that do not specify their own symbol.</p>
66

77
<p><img src="AddGraphicsWithRenderer.png"/></p>
88

src/main/java/com/esri/samples/displayinformation/show_callout/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<h1>Display Callout</h1>
1+
<h1>Show Callout</h1>
22

33
<p>Demonstrates how to show coordinates for a clicked location on an ArcGISMap in a Callout.</p>
44

384 KB
Loading
Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
/*
2+
* Copyright 2016 Esri.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
package com.esri.samples.featurelayers.feature_collection_layer;
17+
18+
import java.util.ArrayList;
19+
import java.util.HashMap;
20+
import java.util.List;
21+
import java.util.Map;
22+
23+
import javafx.application.Application;
24+
import javafx.scene.Scene;
25+
import javafx.scene.layout.StackPane;
26+
import javafx.stage.Stage;
27+
28+
import com.esri.arcgisruntime.data.Feature;
29+
import com.esri.arcgisruntime.data.FeatureCollection;
30+
import com.esri.arcgisruntime.data.FeatureCollectionTable;
31+
import com.esri.arcgisruntime.data.Field;
32+
import com.esri.arcgisruntime.geometry.GeometryType;
33+
import com.esri.arcgisruntime.geometry.Point;
34+
import com.esri.arcgisruntime.geometry.PolygonBuilder;
35+
import com.esri.arcgisruntime.geometry.PolylineBuilder;
36+
import com.esri.arcgisruntime.geometry.SpatialReference;
37+
import com.esri.arcgisruntime.geometry.SpatialReferences;
38+
import com.esri.arcgisruntime.layers.FeatureCollectionLayer;
39+
import com.esri.arcgisruntime.mapping.ArcGISMap;
40+
import com.esri.arcgisruntime.mapping.Basemap;
41+
import com.esri.arcgisruntime.mapping.view.MapView;
42+
import com.esri.arcgisruntime.symbology.SimpleFillSymbol;
43+
import com.esri.arcgisruntime.symbology.SimpleLineSymbol;
44+
import com.esri.arcgisruntime.symbology.SimpleMarkerSymbol;
45+
import com.esri.arcgisruntime.symbology.SimpleMarkerSymbol.Style;
46+
import com.esri.arcgisruntime.symbology.SimpleRenderer;
47+
48+
public class FeatureCollectionLayerSample extends Application {
49+
50+
private MapView mapView;
51+
52+
private static final SpatialReference WGS84 = SpatialReferences.getWgs84();
53+
54+
@Override
55+
public void start(Stage stage) throws Exception {
56+
57+
try {
58+
// create stack pane and application scene
59+
StackPane stackPane = new StackPane();
60+
Scene scene = new Scene(stackPane);
61+
62+
// set title, size, and add scene to stage
63+
stage.setTitle("Feature Collection Layer Sample");
64+
stage.setWidth(800);
65+
stage.setHeight(700);
66+
stage.setScene(scene);
67+
stage.show();
68+
69+
// create amp and set it to be displayed in this view
70+
ArcGISMap map = new ArcGISMap(Basemap.createOceans());
71+
mapView = new MapView();
72+
mapView.setMap(map);
73+
74+
// set initial location for view
75+
mapView.setViewpointCenterAsync(new Point(-79.497238, 8.849289, WGS84), 1000000);
76+
77+
// create feature collection and add to the map as a layer
78+
FeatureCollection featureCollection = new FeatureCollection();
79+
FeatureCollectionLayer featureCollectionLayer = new FeatureCollectionLayer(featureCollection);
80+
map.getOperationalLayers().add(featureCollectionLayer);
81+
82+
// add point, line, and polygon geometry to feature collection
83+
createPointTable(featureCollection);
84+
createPolylineTable(featureCollection);
85+
createPolygonTables(featureCollection);
86+
87+
// add the map view to stack pane
88+
stackPane.getChildren().addAll(mapView);
89+
} catch (Exception e) {
90+
// on any error, display the stack trace.
91+
e.printStackTrace();
92+
}
93+
}
94+
95+
/**
96+
* Creates a Point Feature Collection Table with one Point and adds it to the Feature collection that was passed.
97+
*
98+
* @param featureCollection that the point Feature Collection Table will be added to
99+
*/
100+
private void createPointTable(FeatureCollection featureCollection) {
101+
102+
// defines the schema for the geometry's attribute
103+
List<Field> pointFields = new ArrayList<>();
104+
pointFields.add(Field.createString("Place", "Place Name", 50));
105+
106+
// a feature collection table that creates point geometry
107+
FeatureCollectionTable pointsTable = new FeatureCollectionTable(pointFields, GeometryType.POINT, WGS84);
108+
109+
// set a default symbol for features in the collection table
110+
SimpleMarkerSymbol markerSymbol = new SimpleMarkerSymbol(Style.TRIANGLE, 0xFFFF0000, 18);
111+
SimpleRenderer renderer = new SimpleRenderer(markerSymbol);
112+
pointsTable.setRenderer(renderer);
113+
114+
// add feature collection table to feature collection
115+
featureCollection.getTables().add(pointsTable);
116+
117+
// create feature using the collection table by passing an attribute and geometry
118+
Map<String, Object> attributes = new HashMap<>();
119+
attributes.put(pointFields.get(0).getName(), "Current Location");
120+
Point point = new Point(-79.497238, 8.849289, WGS84);
121+
Feature addedFeature = pointsTable.createFeature(attributes, point);
122+
123+
// add feature to collection table
124+
pointsTable.addFeatureAsync(addedFeature);
125+
}
126+
127+
/**
128+
* Creates a PolyLine Feature Collection Table with one PolyLine and adds it to the Feature collection that was passed.
129+
*
130+
* @param featureCollection that the polyline Feature Collection Table will be added to
131+
*/
132+
private void createPolylineTable(FeatureCollection featureCollection) {
133+
134+
// defines the schema for the geometry's attribute
135+
List<Field> polylineFields = new ArrayList<>();
136+
polylineFields.add(Field.createString("Boundary", "Boundary Name", 50));
137+
138+
// a feature collection table that creates polyline geometry
139+
FeatureCollectionTable polylineTable = new FeatureCollectionTable(polylineFields, GeometryType.POLYLINE, WGS84);
140+
141+
// set a default symbol for features in the collection table
142+
SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.DASH, 0xFF00FF00, 3);
143+
SimpleRenderer renderer = new SimpleRenderer(lineSymbol);
144+
polylineTable.setRenderer(renderer);
145+
146+
// add feature collection table to feature collection
147+
featureCollection.getTables().add(polylineTable);
148+
149+
// create feature using the collection table by passing an attribute and geometry
150+
Map<String, Object> attributes = new HashMap<>();
151+
attributes.put(polylineFields.get(0).getName(), "AManAPlanACanalPanama");
152+
PolylineBuilder builder = new PolylineBuilder(WGS84);
153+
builder.addPoint(new Point(-79.497238, 8.849289, WGS84));
154+
builder.addPoint(new Point(-80.035568, 9.432302, WGS84));
155+
Feature addedFeature = polylineTable.createFeature(attributes, builder.toGeometry());
156+
157+
// add feature to collection table
158+
polylineTable.addFeatureAsync(addedFeature);
159+
}
160+
161+
/**
162+
* Creates a Polygon Feature Collection Table with one Polygon and adds it to the Feature collection that was passed.
163+
*
164+
* @param featureCollection that the polygon Feature Collection Table will be added to
165+
*/
166+
private void createPolygonTables(FeatureCollection featureCollection) {
167+
168+
// defines the schema for the geometry's attribute
169+
List<Field> polygonFields = new ArrayList<>();
170+
polygonFields.add(Field.createString("Area", "Area Name", 50));
171+
172+
// a feature collection table that creates polygon geometry
173+
FeatureCollectionTable polygonTable = new FeatureCollectionTable(polygonFields, GeometryType.POLYGON, WGS84);
174+
175+
// set a default symbol for features in the collection table
176+
SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, 0xFF0000FF, 2);
177+
SimpleFillSymbol fillSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.DIAGONAL_CROSS, 0xFF00FFFF, lineSymbol);
178+
SimpleRenderer renderer = new SimpleRenderer(fillSymbol);
179+
polygonTable.setRenderer(renderer);
180+
181+
// add feature collection table to feature collection
182+
featureCollection.getTables().add(polygonTable);
183+
184+
// create feature using the collection table by passing an attribute and geometry
185+
Map<String, Object> attributes = new HashMap<>();
186+
attributes.put(polygonFields.get(0).getName(), "Restricted area");
187+
PolygonBuilder builder = new PolygonBuilder(WGS84);
188+
builder.addPoint(new Point(-79.497238, 8.849289, WGS84));
189+
builder.addPoint(new Point(-79.337936, 8.638903, WGS84));
190+
builder.addPoint(new Point(-79.11409, 8.895422, WGS84));
191+
Feature addedFeature = polygonTable.createFeature(attributes, builder.toGeometry());
192+
193+
// add feature to collection table
194+
polygonTable.addFeatureAsync(addedFeature);
195+
}
196+
197+
/**
198+
* Stops and releases all resources used in application.
199+
*/
200+
@Override
201+
public void stop() throws Exception {
202+
203+
if (mapView != null) {
204+
mapView.dispose();
205+
}
206+
}
207+
208+
/**
209+
* Opens and runs application.
210+
*
211+
* @param args arguments passed to this application
212+
*/
213+
public static void main(String[] args) {
214+
215+
Application.launch(args);
216+
}
217+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<h1>Feature Collection Layer</h1>
2+
3+
<p>Demonstrates how to create a new Feature Collection with a Point, Polyline, and Polygon Feature Collection Table. The Feature Collection is then displayed on the ArcGISMap as a Layer.</p>
4+
5+
<p><img src="FeatureCollectionLayer.PNG"/></p>
6+
7+
<h2>How it works</h2>
8+
9+
<p>To display a <code>FeatureCollection</code> as a <code>FeatureCollectionLayer</code> on an <code>ArcGISMap</code> using different <code>FeatureCollectionTable</code>s:</p>
10+
11+
<ol>
12+
<li>Create a feature collection layer using a new feature collection, <code>new FeatureCollectionLayer(featureCollection)</code></li>
13+
<li>The layer is then added to the map, <code>ArcGISap.getOperationalLayers().add(featureCollectionLayer)</code>.</li>
14+
<li>A feature collection table is then created for the <code>GeometryType</code>s <code>Point</code> <code>Polyline</code> <code>Polygon</code>, <code>new FeatureCollectionTable(fields, geometryType, spatialRefernce)</code></li>
15+
<ol>
16+
<li><code>Field</code>s is a list of the feature's attributes, which this one defines it's name.</li>
17+
</ol>
18+
<li>A <code>SimpleRenderer</code> is then assigned to each table which will render any <code>Feature</code>s from that table using the <code>Symbol</code> that was set.</li>
19+
<li>The table is then added to the feature collection, <code>FeatureCollection.getTables().add(featureCollectionTable)</code>.</li>
20+
<li>To create a feature from the feature collection table use the createFeature method passing an attribute and geometry for that feature, <code>FeatureCollectionTable.createFeature(attributes, geometry)</code>.</li>
21+
<li>Add new feature to the table, <code>FeatureCollectionTable.addFeatureAsync(feature)</code>.</li>
22+
</ol>
23+
24+
<h2>Features</h2>
25+
26+
<ul>
27+
<li>FeatureCollection</li>
28+
<li>FeatureCollectionLayer</li>
29+
<li>FeatureCollectionTable</li>
30+
<li>Feature</li>
31+
<li>Field</li>
32+
<li>SimpleFillSymbol</li>
33+
<li>SimpleLineSymbol</li>
34+
<li>SimpleMarkerSymbol</li>
35+
<li>SimpleRenderer</li>
36+
</ul>
474 KB
Loading
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/*
2+
* Copyright 2016 Esri.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
17+
package com.esri.samples.featurelayers.feature_layer_geodatabase;
18+
19+
import java.io.File;
20+
21+
import javafx.application.Application;
22+
import javafx.scene.Scene;
23+
import javafx.scene.layout.StackPane;
24+
import javafx.stage.Stage;
25+
26+
import com.esri.arcgisruntime.data.Geodatabase;
27+
import com.esri.arcgisruntime.data.GeodatabaseFeatureTable;
28+
import com.esri.arcgisruntime.layers.FeatureLayer;
29+
import com.esri.arcgisruntime.mapping.ArcGISMap;
30+
import com.esri.arcgisruntime.mapping.Basemap;
31+
import com.esri.arcgisruntime.mapping.view.MapView;
32+
33+
public class FeatureLayerGeodatabase extends Application {
34+
35+
private MapView mapView;
36+
37+
@Override
38+
public void start(Stage stage) throws Exception {
39+
40+
try {
41+
42+
// create stack pane and JavaFX app scene
43+
StackPane stackPane = new StackPane();
44+
Scene fxScene = new Scene(stackPane);
45+
46+
// set title, size, and add JavaFX scene to stage
47+
stage.setTitle("Feature Layer Geodatabase Sample");
48+
stage.setWidth(800);
49+
stage.setHeight(700);
50+
stage.setScene(fxScene);
51+
stage.show();
52+
53+
// create map and add to view
54+
ArcGISMap map = new ArcGISMap(Basemap.createStreets());
55+
mapView = new MapView();
56+
mapView.setMap(map);
57+
58+
// create geodatabase from local resource
59+
String geodatabaseUrl = new File("samples-data/los_angeles/LA_Trails.geodatabase").getAbsolutePath();
60+
Geodatabase geodatabase = new Geodatabase(geodatabaseUrl);
61+
geodatabase.addDoneLoadingListener(() -> {
62+
// access the geodatabase's feature table Trailheads
63+
GeodatabaseFeatureTable geodatabaseFeatureTable = geodatabase.getGeodatabaseFeatureTable("Trailheads");
64+
65+
// create a layer from the geodatabase feature table above and add to map
66+
FeatureLayer featureLayer = new FeatureLayer(geodatabaseFeatureTable);
67+
featureLayer.addDoneLoadingListener(() -> {
68+
// set viewpoint to the location of feature layer's features
69+
mapView.setViewpointCenterAsync(featureLayer.getFullExtent().getCenter(), 1000000);
70+
});
71+
// display feature layer to the map view
72+
map.getOperationalLayers().add(featureLayer);
73+
});
74+
// load geodatabase
75+
geodatabase.loadAsync();
76+
77+
// add the map view to stack pane
78+
stackPane.getChildren().addAll(mapView);
79+
} catch (Exception e) {
80+
// on any error, display the stack trace.
81+
e.printStackTrace();
82+
}
83+
}
84+
85+
/**
86+
* Stops and releases all resources used in application.
87+
*/
88+
@Override
89+
public void stop() {
90+
91+
if (mapView != null) {
92+
mapView.dispose();
93+
}
94+
}
95+
96+
/**
97+
* Opens and runs application.
98+
*
99+
* @param args arguments passed to this application
100+
*/
101+
public static void main(String[] args) {
102+
103+
Application.launch(args);
104+
}
105+
106+
}

0 commit comments

Comments
 (0)