Select to view content in your preferred language

Is there a way to run queries via the feature layer api call?

220
2
Jump to solution
10-14-2024 02:02 PM
JonKnight
New Contributor

 

 

    var livingAtlasLayer2 = new FeatureLayer({
        url: "https://services9.arcgis.com/RHVPKKiFTONKtxq3/arcgis/rest/services/USGS_Seismic_Data_v1/FeatureServer/query?outFields=*&where=Hours_Old%20%3C%20100"
    });

 

 So I am trying to run queries when creating a feature layer. So far, it just seems to ignore the query altogether and run the layer as normal. Is there a way to make this work using this method? I know normal api calls, this can work, depending on the source. 

My intent here is to control the data so that I only get the most recent data to show up. 

0 Kudos
1 Solution

Accepted Solutions
JohnGrayson
Esri Regular Contributor

What is the intent?  To filter the data being displayed on the map, or to query and retrieve a subset of the data that match your query parameters?

Filter data displayed on the Map
FeatureLayer.definitionExpression 

Rretrieve a subset of the data that match your query parameters
FeatureLayer.queryFeatures(...) 

View solution in original post

0 Kudos
2 Replies
JohnGrayson
Esri Regular Contributor

What is the intent?  To filter the data being displayed on the map, or to query and retrieve a subset of the data that match your query parameters?

Filter data displayed on the Map
FeatureLayer.definitionExpression 

Rretrieve a subset of the data that match your query parameters
FeatureLayer.queryFeatures(...) 

0 Kudos
JonKnight
New Contributor

To make a window of the data that is closer to the present, so the data showing is only the more recent data (in this case, only the more recent earthquakes). That's my intent. Whatever accomplishes that intent, that makes it work with the map I've put together using ArcGIS, I am down for. I guess I should have also mentioned, I am using version 4.22 

Thank you so much for pointing the way. I am still very new to making all of this work, so this is so very appreciated! 

0 Kudos