I wish to find all the features within a polygon/circle drawn by my user.
May I know if I should use IdentifyTask
https://developers.arcgis.com/en/javascript/jsapi/identifytask.html
Or is there a more recommended way?
Use Case: User drawn a circle/polygon and it will display all the address within the area.
-
Are all the features within a single layer in the mapservice?Kirk Kuykendall– Kirk Kuykendall2013年07月09日 02:22:52 +00:00Commented Jul 9, 2013 at 2:22
-
yes, apparently identifytask only return a feature...any help on this?seesee– seesee2013年07月09日 02:24:03 +00:00Commented Jul 9, 2013 at 2:24
-
The Identify task allows you to specify which layers in the mapservice you are interested in, whereas the Query task is for a particular layer.Kirk Kuykendall– Kirk Kuykendall2013年07月09日 02:27:06 +00:00Commented Jul 9, 2013 at 2:27
2 Answers 2
The solution is to use QueryTask.
https://developers.arcgis.com/en/javascript/jsapi/querytask.html
It accepts a Query
https://developers.arcgis.com/en/javascript/jsapi/query.html
which the a geometry parameter can be input to search for features within the specified criterias.
Using QueryTask.execute(parameters,callback,errback) method. It will return a feature set on onComplete(featureSet) callback.
which contains a property call features
https://developers.arcgis.com/en/javascript/jsapi/featureset.html.
By looping through the features[]. We can get the set of features within the geometry.
You can specify the geometry using the identifyparameters class: https://developers.arcgis.com/en/javascript/jsapi/identifyparameters.html
It will accept any type of geometry, typically you would pass it a point, but you could pass in a polygon that is drawn on the screen.
-
yes but apparently it only return a feature. I am trying to find all the address within a geometry.seesee– seesee2013年07月09日 02:27:18 +00:00Commented Jul 9, 2013 at 2:27
-
It returns an identifyResult, not a feature: developers.arcgis.com/en/javascript/jsapi/identifyresult.htmlCLJ– CLJ2013年07月09日 02:33:42 +00:00Commented Jul 9, 2013 at 2:33
-
An identified feature. - yes 1 feature only.seesee– seesee2013年07月09日 02:36:48 +00:00Commented Jul 9, 2013 at 2:36
-
I don't think you understand. The identify result does not return a single feature, it returns a identifyresult, which is an object that contains an array of features. The identifytask can query multiple layers and return features from these layers. Perhaps you need to rephrase your question.CLJ– CLJ2013年07月09日 10:23:04 +00:00Commented Jul 9, 2013 at 10:23
-
developers.arcgis.com/en/javascript/jsapi/identifyresult.html in the properties you will see "feature" only. It will return a single feature. What I need is queryTask. developers.arcgis.com/en/javascript/jsapi/querytask.html which returns a featuresetseesee– seesee2013年07月09日 16:39:26 +00:00Commented Jul 9, 2013 at 16:39
Explore related questions
See similar questions with these tags.