Learn how to use a URL to access and
display a feature layer in a map.
A feature layer is a visual representation of feature table data. Feature layers contain features with a geometry type (point, line, or polygon), and attributes. You can use feature layers to store, access, and manage large amounts of geographic data for your applications. You can access features from a feature layer using its underlying feature table.
In this tutorial, you use a URL to create, access, and display a feature layer in your app by first creating a local feature table from an ArcGIS Online service: Trailheads (points).
Prerequisites
The following are required for this tutorial:
An ArcGIS account to access API keys. If you don't have an account, sign up for free.
Click File > Sync Project with Gradle files. Android Studio will recognize your changes and create a new .idea folder.
If you downloaded the solution project, set your API key.
An API Key enables access to services, web maps, and web scenes hosted in ArcGIS Online.
Go to your developer dashboard to get your API key.
For these tutorials, use your default API key. It is scoped to include all of the services demonstrated in the tutorials.
In Android Studio: in the Android tool window, open app > java > com.example.app > MainActivity.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// set up your map here. You will call this method from onCreate()privatefunsetupMap() {
// create a map with the BasemapStyle topographicval map = ArcGISMap(BasemapStyle.ARCGIS_TOPOGRAPHIC)
// set the map to be displayed in the layout's MapView mapView.map = map
// set the viewpoint, Viewpoint(latitude, longitude, scale) mapView.setViewpoint(Viewpoint(34.0270, -118.8050, 200000.0))
}
Expand
Create a service feature table to reference feature service data
To display a new data layer (also known as an operational layer) on top of the current basemap, you will create a ServiceFeatureTable using an URL to reference the dataset hosted in ArcGIS Online.
Open a browser and navigate to the URL for Parks and Open Spaces to view metadata about the layer. To display the layer in your ArcGIS Runtime app, you only need the URL.
The service page provides information such as the geometry type, the geographic extent, the minimum and maximum scale at which features are visible, and the attributes (fields) it contains. You can preview the layer by clicking on ArcGIS.com Map in the "View In:" list at the top of the page.
You will create a new FeatureLayer to display the hosted layer above the basemap.
Create a new FeatureLayer using the service feature table and add it to the map as a data (operational) layer.
If an app has multiple data layers, they are displayed in the order in which they are added to the app.
A FeatureLayer is simply a reference to a feature service and a fast and easy way to add data to a map. It is accessed via a URL which specifies the endpoint. By default, the API will try to load all of the features that fit into the current view.