Introduction to data services

Data services, also known as hosted data services, are services hosted in a portal that are used to securely store, manage, and access geographic data. They are typically created as an item in your organization's portal.

You can access data from data services by creating client-side data layers in your application. These are also known as operational layers, and can be used to display features, vector tiles, map tiles, and more.

Feature layers

If you have features containing geometry and attributes, you can import the data to create an ArcGIS feature layer in a feature service. To access the data, you can use the URL of the service to query and return features. You can style and display the results in a map or scene. Feature layers can also contain styling information as part of the service response.

How to access a feature service

  1. Import your data from a CSV, XLS, GeoJSON, or Shapefile file to create a hosted feature layer.
  2. Get the URL for the feature layer.
  3. Reference the MapLibre JS and CSS libraries.
  4. Define a data source to access and query the feature layer.
  5. Display the data in a layer.

Example

This example demonstrates how to display a feature layer. To get GeoJSON features from a feature layer, you need to provide a URL that queries the feature service and return the features in GeoJSON format.

Display a feature layer (as GeoJSON)

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<script src="https://unpkg.com/maplibre-gl@4.0.0/dist/maplibre-gl.js"></script>
<link href="https://unpkg.com/maplibre-gl@4.0.0/dist/maplibre-gl.css" rel="stylesheet" />
<script>

   map.addSource("trailheads", {
   type: "geojson",
   data: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0/query?f=pgeojson&where=1=1",
   });

   map.addLayer({
   id: "trailheads-circle",
   type: "circle",
   source: "trailheads",
   paint: {
      "circle-color": "hsla(0,0%,0%,0.75)",
      "circle-stroke-width": 1.5,
      "circle-stroke-color": "white",
   }
   });
</script>

Vector tile layers

If you want to access and display your data as vector tile data, you can publish a vector tile layer from a feature layer, and then display it in a map. Vector tile layers closely follow the Mapbox vector tile specification, but there a few important differences:

  • URL endpoints end in /{z}/{y}/{x}.pbf, rather than /{z}/{x}/{y}.pbf.
  • Each style may contain one source.
  • The raster and hillshade layer types are not supported.

How to access the vector tile service

  1. Import your data from a CSV, XLS, GeoJSON, or Shapefile file to create a hosted feature layer.
  2. Style the feature layer using the Map Viewer.
  3. Create a vector tile service by publishing the feature layer as a vector tile layer.
  4. Get the URL.
  5. Reference the MapLibre JS and CSS libraries.
  6. Set the source as the type vector and add the tiles.
  7. Define the style of the vector tile layer, found in the Style tab of the item page in your portal.

Example

Display a vector tile layer

This example demonstrates how you fetch the vector tiles and then use a layer of type fill to display the tiles.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<script src="https://unpkg.com/maplibre-gl@4.0.0/dist/maplibre-gl.js"></script>
<link href="https://unpkg.com/maplibre-gl@4.0.0/dist/maplibre-gl.css" rel="stylesheet" />
<script>

   map.addSource("parcels", {
   type: "vector",
   tiles: ["https://vectortileservices3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Santa_Monica_Mountains_Parcels_VTL/VectorTileServer/tile/{z}/{y}/{x}.pbf"]
   });

   map.addLayer({
   id: "parcels-fill",
   type: "fill",
   source: "parcels",
   "source-layer": "Santa_Monica_Mountains_Parcels",
   paint: {
      "fill-color": "hsl(200, 80%, 50%)",
      "fill-opacity": 0.5,
      "fill-outline-color": "white"
   }
   });

</script>

Map tile layers

If you want to access and display your data as a tile layer, you can publish a map tile layer from a feature layer, and then display it in a map.

How to access a map tile service

  1. Import your data from a CSV, XLS, GeoJSON, or Shapefile file to create a hosted feature layer.
  2. Create a tile layer in your portal by navigating to its item page > Publish > Tile layer.
  3. Get the URL.
  4. Reference the MapLibre JS and CSS libraries.
  5. Define the source as the type raster and add the layer.

Example

Display a map tile layer

The example shows how to fetch raster tiles from a map tile service and display them on the map with a layer of type raster.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<script src="https://unpkg.com/maplibre-gl@4.0.0/dist/maplibre-gl.js"></script>
<link href="https://unpkg.com/maplibre-gl@4.0.0/dist/maplibre-gl.css" rel="stylesheet" />
<script>

   map.addSource("parcels", {
      type: "raster",
      tiles: [
      "https://server.arcgisonline.com/arcgis/rest/services/Elevation/World_Hillshade/MapServer/tile/{z}/{y}/{x}.jpeg?token=" + accessToken
      ]
   });

   map.addLayer({
     id: "hillshade-raster",
     type: "raster",
     source: "hillshade"
   });

</script>

Tutorials

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