How to query ARCGIS REST Service via ajax with street address

919
5
09-28-2017 11:32 AM
AssiaAlexandrova
New Contributor

Not very familiar with the necessary GIS concepts so this is a beginner question. From my web app I am querying a GIS REST Service using this query:

require([ "dojo/dom", "dojo/on", "esri/tasks/query", "esri/tasks/QueryTask", "dojo/domReady!" ], function (dom, on, Query, QueryTask) {

var queryTask = new QueryTask("http://gis.something.org/arcgis/rest/services/XXXX/Operational/MapServer/6");
var query = new Query();
query.returnGeometry = false;
query.outFields = [
"DISTRICTID "
];

query.where = "SUBID = '" + SUBJID + "'";

queryTask.execute(query, showResults);

In this scenario I had a subject ID (SUBID) which I used for the query to return which district the subject falls in (i.e. the respective DistrictID). I now want to query the service by street address, rather than by SUBID. Any pointers how to structure the query in this case?

0 Kudos
5 Replies
RobertScheitlin__GISP
MVP Emeritus

Assia,

   So you want to include your street address field in your out fields (most likely) and then change your query.where.

query.outFields = ["*"];
 
query.where = "ST_ADD LIKE '%" + STADD + "'%";
AssiaAlexandrova
New Contributor

Thank you, Robert!

Is ST_ADD a universal convention for naming the street address field or will I have to find out what the equivalent of that is in this particular service?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Assia,

   That was just an example. You will have to figure out what the field name is in your data (assuming you do have a field with street address info).

AssiaAlexandrova
New Contributor

Thank you again!

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Don't forget to mark this question as answered by clicking on the "Correct Answer" link on the reply that answered your question.

0 Kudos