0

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.

asked Jul 9, 2013 at 0:36
3
  • Are all the features within a single layer in the mapservice? Commented Jul 9, 2013 at 2:22
  • yes, apparently identifytask only return a feature...any help on this? Commented 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. Commented Jul 9, 2013 at 2:27

2 Answers 2

1

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.

answered Jul 9, 2013 at 16:45
0

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.

answered Jul 9, 2013 at 2:24
7
  • yes but apparently it only return a feature. I am trying to find all the address within a geometry. Commented Jul 9, 2013 at 2:27
  • It returns an identifyResult, not a feature: developers.arcgis.com/en/javascript/jsapi/identifyresult.html Commented Jul 9, 2013 at 2:33
  • An identified feature. - yes 1 feature only. Commented 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. Commented 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 featureset Commented Jul 9, 2013 at 16:39

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.