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
To perform SQL and spatial queries, you reference the main Esri Leaflet plugin. The L.esri.Query
operation can be used to query feature, map, and image services.
Steps
- Reference the Esri Leaflet plugin.
- Find the URL of the service against which you want to query.
- Set the service URL and the feature layer ID.
- Define the SQL or spatial query.
Example
Query a feature layer (spatial)
In this example, you perform a spatial query to find which parcels intersect a geometry. Available spatial queries include: within, contains, intersects, and overlaps.
Learn more in the Query a feature layer (SQL) and Query a feature layer (spatial) tutorials. If you want to learn about querying related records using the L.esri.Related.Query
, go to the API reference.