Introduction to querying data

A feature service is a type of data service that stores spatial data (features) and non-spatial data. It provides access to the data with feature layers and tables. You can use SQL queries, spatial queries, or a combination of both to get data from a feature service. The results can be used for further processing or displayed in an application.

How to query a feature service

There is no direct integration with MapLibre to construct a SQL or spatial query against a hosted feature service. To access the feature service in your application, you use the feature-service and request modules from ArcGIS REST JS. The feature-service module allows you to query and edit features in a feature layer.

Example

Query a feature layer (spatial)

In this example, you perform a spatial query using the ArcGIS REST JS request and feature-service modules to find which parcels intersect a geometry. Available spatial relationships include: within, contains, intersects, and overlaps.

Use dark colors for code blocksCopy
                 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<script src="https://unpkg.com/@esri/arcgis-rest-request@4.0.0/dist/bundled/request.umd.js"></script>
<script src="https://unpkg.com/@esri/arcgis-rest-feature-service@4.0.0/dist/bundled/feature-service.umd.js"></script>
<script>
  arcgisRest
  .queryFeatures({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/LA_County_Parcels/FeatureServer/0",
    geometry: queryGeometry,
    geometryType: "esriGeometryPoint",
    spatialRel: "esriSpatialRelIntersects",
    authentication
  })
  .then((response) => {
    console.log(response.features);
    document.getElementById("result").textContent = JSON.stringify(response.features, null, 2);
  });

</script>

To learn more, go to the Query a feature layer (spatial) and Query a feature layer (SQL) tutorials.

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