Hosted feature layers

Feature layers displaying trailhead, trail, and park data stored as hosted feature layers

What is a hosted feature layer?

A hosted feature layer is a reference to a feature layer in a feature service used to store your data. A feature layer is a spatially-enabled table that contains features with a geometry and attributes. Applications can use feature layers to access, query, edit, and display features in a map or scene.

You use a hosted feature layer when you want to:

  • Import files such as CSV, XLS, or Google Sheets with coordinate information.
  • Store collections of geometry and attribute data as features.
  • Access and display features in maps and scenes.
  • Securely share data with applications and users.
  • Optimize accessing and displaying large amounts of features.
  • Edit data and track edits.
  • Perform SQL or spatial queries.
  • Update or export data.
  • Use feature data in offline applications.

How a hosted feature layer works

You create a hosted feature layer by using data management tools to import files such as CSV, XLS, GeoJSON, Shapefile, and File Geodatabase files or by publishing feature data. When a hosted feature layer is created, an item and a feature layer in a feature service are created. The item ID is a unique identifier for the layer. You use an item page to manage a feature layer and a feature service to access the data.

Data hosting

Access hosted feature layers and feature services from your applications.

Manage a feature layer

An item page allows you to manage the properties and capabilities for a hosted feature layer. You can access an item page by signing in to your developer dashboard or ArcGIS Online. You can set properties such as the name, description, and tags, as well as sharing, editing, and index settings.

View a feature layer item page

To access an item page directly, use a portal search URL with the ID for the item. The portal URL for data hosted in the ArcGIS Platform is https://www.arcgis.com. To use this URL, the item must be shared publicly.

 
1
https://www.arcgis.com/home/item.html?id=<ID>

Example: https://www.arcgis.com/home/item.html?id=883cedb8c9fe4524b64d47666ed234a7

Access a feature layer

You can discover information about a feature layer by accessing the feature service endpoint with the layer ID. The ID is typically an integer such as "0" if there is only one layer in the feature service. Accessing the endpoint in a web browser allows you to view properties such as the name, geometry type, drawing information, extent, and fields. Most APIs will use the endpoint to perform other operations such as querying data.

Get feature layer properties

To access a feature layer or get properties, use the host, unique service ID, service name, and the layer ID.

 
1
https://<host>/<uniqueID>/ArcGIS/rest/services/<serviceName>/FeatureServer/<layerID>

Example: https://services3.arcgis.com/GVgbJbqm8hXASVYi/ArcGIS/rest/services/Trailheads/FeatureServer/0

Get feature layer data

To get feature layer data, use the host, unique service ID, service name, layer ID, and a query operation with parameters. You can provide a SQL or spatial query and the data can be returned as HTML, JSON, or GeoJSON.

 
1
https://<host>/<uniqueID>/ArcGIS/rest/services/<serviceName>/FeatureServer/0/query?<params>

Examples:

HTML: https://services3.arcgis.com/GVgbJbqm8hXASVYi/ArcGIS/rest/services/Trailheads/FeatureServer/0/query?where=1=1&outFields=*&f=html

JSON: https://services3.arcgis.com/GVgbJbqm8hXASVYi/ArcGIS/rest/services/Trailheads/FeatureServer/0/query?where=1=1&outFields=*&f=json

GeoJSON: https://services3.arcgis.com/GVgbJbqm8hXASVYi/ArcGIS/rest/services/Trailheads/FeatureServer/0/query?where=1=1&outFields=*&f=geojson

Examples

Display a feature layer

To display a hosted feature layer, you reference the layer by its URL or ID, and then add it to a map or scene. The API communicates with the feature service to retrieve data for the current visible extent. ArcGIS APIs optimize data access by utilizing feature service functionality such as spatial indexes and caching. APIs also need to specify which data attributes to return.

Steps

  1. Create a map or scene.
  2. Get the hosted feature layer URL.
  3. Add the layer.

ArcGIS JS APIEsri LeafletMapbox GL JSOpenLayersArcGIS .NET APIArcGIS Android APIArcGIS iOS APIArcGIS Java APIArcGIS Qt API (C++)ArcGIS Qt API (QML)
                                                                
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
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
  <title>ArcGIS Developer Guide: Data layers (Feature layers)</title>
  <style>
    html, body, #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
  </style>

<link rel="stylesheet" href="https://js.arcgis.com/4.19/esri/themes/light/main.css">
<script src="https://js.arcgis.com/4.19/"></script>

  <script>
    require([
      "esri/config",
      "esri/Map",
      "esri/views/MapView",
      "esri/layers/FeatureLayer"
    ], (esriConfig, Map, MapView, FeatureLayer)=> {
      esriConfig.apiKey = "YOUR-API-KEY";
      const map = new Map({
        basemap: "arcgis-topographic" //Basemap service
      const view = new MapView({
        container: "viewDiv",
        map: map,
        center: [-118.80543,34.02700], //Longitude, latitude
        zoom: 13,
        constraints: {
          snapToZoom: false
      const trailheadsLayer = new FeatureLayer({
        url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads_styled/FeatureServer/0"
      });
      map.add(trailheadsLayer);

      const trailsLayer = new FeatureLayer({
        url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails_styled/FeatureServer/0"
      });
      map.add(trailsLayer,0);

      const parksLayer = new FeatureLayer({
        url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Parks_and_Open_Space_styled/FeatureServer/0"
      });
      map.add(parksLayer,0);
  </script>
</head>
<body>
  <div id="viewDiv"></div>
</body>
</html>

Query a feature layer (Spatial)

To retrieve a sub-set of data for a hosted feature layer, you can query features using a spatial relation and a geometry. This example uses a spatial query to access a sub-set of parcels from a feature layer that contains 2.4 million features.

Steps

  1. Create a map or scene.
  2. Get the hosted feature layer URL.
  3. Create and execute a spatial query.
  4. Show the features.
ArcGIS JS APIEsri LeafletMapbox GL JSOpenLayersArcGIS .NET APIArcGIS Android APIArcGIS iOS APIArcGIS Java APIArcGIS Qt API (C++)ArcGIS Qt API (QML)
                                                                                                                     
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
  <title>ArcGIS API for JavaScript Tutorials: Query a feature layer (spatial)</title>
  <style>
    html, body, #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
  </style>
  <link rel="stylesheet" href="https://js.arcgis.com/4.19/esri/themes/light/main.css">
  <script src="https://js.arcgis.com/4.19/"></script>
  <script>
    require([
      "esri/config",
      "esri/Map",
      "esri/views/MapView",
      "esri/widgets/Sketch",
      "esri/layers/GraphicsLayer",
      "esri/layers/FeatureLayer"
    ],(esriConfig, Map, MapView, Sketch, GraphicsLayer, FeatureLayer)=> {
      esriConfig.apiKey = "YOUR-API-KEY";
      const map = new Map({
        basemap: "arcgis-topographic" //Basemap layer service
      const view = new MapView({
        container: "viewDiv",
        map: map,
        center: [-118.80543,34.03000], //Longitude, latitude
        zoom: 13,
        constraints: {
          snapToZoom: false
      // Add sketch widget
      const graphicsLayerSketch = new GraphicsLayer();
      const sketch = new Sketch({
        layer: graphicsLayerSketch,
        view: view,
        creationMode: "update" // Auto-select
      view.ui.add(sketch, "top-right");
      // Add sketch events to listen for and execute query
      sketch.on("update", (event) => {
        // Create
        if (event.state == "start") {
          queryFeaturelayer(event.graphics[0].geometry);
        if (event.state === "complete"){
          graphicsLayerSketch.remove(event.graphics[0]); // Clear the graphic when a user clicks off of it or sketches new one
        // Change
        if (event.toolEventInfo && (event.toolEventInfo.type == "scale-stop" || event.toolEventInfo.type == "reshape-stop" || event.toolEventInfo.type == "move-stop")) {
          queryFeaturelayer(event.graphics[0].geometry);
      // Reference query layer
      const parcelLayer = new FeatureLayer({
        url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/LA_County_Parcels/FeatureServer/0",
      });

      function queryFeaturelayer(geometry) {
        const parcelQuery = {
         spatialRelationship: "intersects", // Relationship operation to apply
         geometry: geometry,  // The sketch feature geometry
         outFields: ["APN","UseType","TaxRateCity","Roll_LandValue"], // Attributes to return
         returnGeometry: true
        };
        parcelLayer.queryFeatures(parcelQuery)
        .then((results) => {
          displayResults(results);
        }).catch((error) => {
          console.log(error);
        });
      };
      // Show features (graphics)
      function displayResults(results) {
      // Create a blue polygon
        const symbol = {
          type: "simple-fill",
          color: [ 20, 130, 200, 0.5 ],
          outline: {
            color: "white",
            width: .5
        const popupTemplate = {
          title: "Parcel {APN}",
          content: "Type: {UseType} <br> Land value: {Roll_LandValue} <br> Tax Rate City: {TaxRateCity}"
        // Set symbol and popup
        results.features.map((feature) => {
          return feature;
        // Clear display
       // Add features to graphics layer
  </script>
</head>
<body>
  <div id="viewDiv"></div>
</body>
</html>

Query a feature layer (SQL)

To retrieve a sub-set of data for a hosted feature layer, you can query features using a SQL where clause. This example uses a SQL where clause to access a sub-set of parcels from a feature layer that contains 2.4 million features.

Steps

  1. Create a map or scene.
  2. Get the hosted feature layer URL.
  3. Create and execute a SQL query.
  4. Show the features.

ArcGIS JS APIEsri LeafletMapbox GL JSOpenLayersArcGIS .NET APIArcGIS Android APIArcGIS iOS APIArcGIS Java APIArcGIS Qt API (C++)ArcGIS Qt API (QML)
                                                                                                                  
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
  <title>ArcGIS API for JavaScript Tutorials: Query a feature layer (SQL)</title>
  <style>
    html, body, #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
    .esri-ui-corner .esri-component.esri-widget--panel {
    width: 230px !important;
  </style>
  <link rel="stylesheet" href="https://js.arcgis.com/4.19/esri/themes/light/main.css">
  <script src="https://js.arcgis.com/4.19/"></script>
  <script>
    require([
      "esri/config",
      "esri/Map",
      "esri/views/MapView",
      "esri/layers/FeatureLayer",
    ], (esriConfig, Map, MapView, FeatureLayer)=> {
      esriConfig.apiKey = "YOUR-API-KEY";
      const map = new Map({
        basemap: "arcgis-topographic" //Basemap layer service
      const view = new MapView({
        container: "viewDiv",
        map: map,
        center: [-118.80543,34.03000], //Longitude, latitude
        zoom: 13,
        constraints: {
          snapToZoom: false
      // SQL query array
      const parcelLayerSQL = ["Choose a SQL where clause...", "UseType = 'Residential'",  "UseType = 'Government'", "UseType = 'Irrigated Farm'", "TaxRateArea = 10853", "TaxRateArea = 10860", "TaxRateArea = 08637", "Roll_LandValue > 1000000", "Roll_LandValue < 1000000"];
      let whereClause = parcelLayerSQL[0];
      // Add SQL UI
      const select = document.createElement("select","");
      select.setAttribute("class", "esri-widget esri-select");
      select.setAttribute("style", "width: 200px; font-family: 'Avenir Next'; font-size: 1em");
      parcelLayerSQL.forEach(function(query){
        let option = document.createElement("option");
      view.ui.add(select, "top-right");
       // Listen for changes
      select.addEventListener('change', (event) => {
      // Get query layer and set up query
      const parcelLayer = new FeatureLayer({
        url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/LA_County_Parcels/FeatureServer/0",
      });

      function queryFeatureLayer(extent) {
        const parcelQuery = {
         where: whereClause,  // Set by select element
         spatialRelationship: "intersects", // Relationship operation to apply
         geometry: extent, // Restricted to visible extent of the map
         outFields: ["APN","UseType","TaxRateCity","Roll_LandValue"], // Attributes to return
         returnGeometry: true
        };
        parcelLayer.queryFeatures(parcelQuery)
        .then((results) => {
          displayResults(results);
        }).catch((error) => {
          console.log(error.error);
        });
      };
      function displayResults(results) {
        // Create a blue polygon
        const symbol = {
          type: "simple-fill",
          color: [ 20, 130, 200, 0.5 ],
          outline: {
            color: "white",
            width: .5
        const popupTemplate = {
          title: "Parcel {APN}",
          content: "Type: {UseType} <br> Land value: {Roll_LandValue} <br> Tax Rate City: {TaxRateCity}"
        // Assign styles and popup to features
        results.features.map((feature) => {
          return feature;
        // Clear display
        // Add features to graphics layer
  </script>
</head>
<body>
  <div id="viewDiv"></div>
</body>
</html>

Tutorials

Services

Feature service

Add, update, delete, and query feature data.


Vector tile service

Store and access vector tile data.


Image tile service

Store and access image tile data.

API support

Tools
Import and create dataManage data accessManage data propertiesDisplay dataQuery dataEdit data
Developer dashboardFully supportedLayers only.Layers and services only.Fully supportedNot supportedNot supported
ArcGIS OnlineFully supportedFully supportedFully supportedFully supportedFully supportedFully supported
Map ViewerCreate layers.Web maps only.Web maps and layers only.Fully supportedFully supportedFully supported
Scene ViewerNot supportedWeb scenes only.Web scenes and layers only.Fully supportedFully supportedNot supported
ArcGIS Pro (desktop)Fully supportedFully supportedFully supportedFully supportedFully supportedFully supported
Full supportPartial support (see notes)Not supported
APIs
Import and create dataDisplay dataQuery dataEdit data
ArcGIS API for JavaScriptNot supportedFully supportedFully supportedFully supported
ArcGIS Runtime API for AndroidNot supportedFully supportedFully supportedFully supported
ArcGIS Runtime API for iOSNot supportedFully supportedFully supportedFully supported
ArcGIS Runtime API for JavaNot supportedFully supportedFully supportedFully supported
ArcGIS Runtime API for .NETNot supportedFully supportedFully supportedFully supported
ArcGIS Runtime API for QtNot supportedFully supportedFully supportedFully supported
ArcGIS API for PythonFully supportedNot supportedFully supportedFully supported
Esri LeafletNot supportedFully supportedRequires ArcGIS REST JSRequires ArcGIS REST JS
MapBox GL JSNot supportedFully supportedRequires ArcGIS REST JSRequires ArcGIS REST JS
OpenLayersNot supportedFully supportedRequires ArcGIS REST JSRequires ArcGIS REST JS
ArcGIS REST JSAuthentication and portal access.Not supportedFully supportedFully supported
Full supportPartial support (see notes)Not supported

Tools

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.