Greetings,
I'm developing an Android app (Java) using the Runtime SDK for Android.
I'm trying to create a definition condition for a FeatureLayer, to only show features with 'Tipo = Autotanque' and with 'Capacidade > 500 (liters)'.
I tried the following lines of code:
featureLayer.setDefinitionExpression("Tipo = 'Autotanque' WHERE CAPACIDADE > '500'");
featureLayer.setDefinitionExpression("Tipo = 'Autotanque' AND CAPACIDADE > '500'");
After testing only the first part of the expression (Tipo = 'Autotanque'), it worked, but the second part of the definition expression is not being read properly as no features are shown.
Please guide me on how to build this expression.
Thank you very much in advance.
Cheers
Solved! Go to Solution.
Hi,
What field type is CAPACIDADE? If it's numeric then you may need to omit the ' ' around the value
e.g. req_Type = 'Tree Maintenance or Damage' AND req_id > 40000
You can test this specific example here: Query: Incidents (ID: 0) (arcgis.com)
Cheers
Hi,
What field type is CAPACIDADE? If it's numeric then you may need to omit the ' ' around the value
e.g. req_Type = 'Tree Maintenance or Damage' AND req_id > 40000
You can test this specific example here: Query: Incidents (ID: 0) (arcgis.com)
Cheers
I accepted this answer as the solution. I found out I had some features not prepared to be queried. After deleting the malfunctioning features, my query went through as successful.
I used the following query
"Capacidade > 500 AND Tipo LIKE 'Autotanque'"
I decided it was more convenient to use FeatureLayer.queryFeaturesAsync rather than the FeatureLayer.setDefinitionExpression.
Cheers
Hello Michael,
Thank you very much for your reply.
I decided it's more convenient to use QueryPameters in FeatureLayer.queryFeaturesAsync for the purpose I want.
Regarding your question, it is a numeric field. I also tried without the quotes ' and had the same result (forgot to mention that).
Thank you very much for your reply
... if you're looking for client-side display filtering you might also consider using Display Filters: Query | ArcGIS Runtime API for .NET | ArcGIS Developers
I have a strange issue related to set a complex definition expression with date field queries to mapservice subLayer the issue was introduced with me in arcgis sdk with ios and with kotlin as well
and then I have made sure this is not related to the sdk itself so I have tried with arcgis js api and I found out this:
- for setting the expression that includes date time queries to feature layer it works well as expected
-for setting the expression that includes date time queries to map service sublayer it doesn't work as expected at all and it returns all features in layer
var dynamicMapServiceLayer = new FeatureLayer({
url: "https://myhost/server/rest/services/App/app/MapServer/1",
id: 'baseMap',
definitionExpression: "USER_NAME = 'test' AND (SIGHTING_DATE >= DATE '2025-02-17' AND SIGHTING_DATE < DATE '2025-02-18')"
});
var dynamicMapServiceLayer = new MapImageLayer({
url: "https://myhost/server/rest/services/App/app/MapServer",
id: 'baseMap',
sublayers: [
{
id: 1,
visible: true,
definitionExpression: "USER_NAME = 'test' AND (SIGHTING_DATE >= DATE '2025-02-17' AND SIGHTING_DATE < DATE '2025-02-18')"
}
]
});
I guess it is an issue with server of how to process definition expression for both
I hope to resolve this issue soon
Hi,
Can you create a new post for your question?
If you're using ArcGIS Runtime SDK for Android 100.x: ArcGIS Runtime SDK for Android Questions - Esri Community
If you're using ArcGIS Maps SDK for Kotlin 200.x: Kotlin Maps SDK Questions - Esri Community
Thanks
I found a solution for this. The reason why this issue is our used database is SQL Server so the syntax for definition expression [for date time] is not proper for SQL Server in export map service request so when I use this:
"USER_NAME = 'test' AND SIGHTING_DATE BETWEEN CAST('2025-02-17' AS DATE ) AND CAST('2025-02-18' AS DATE))"