IdentifyTask - What am I missing?

2664
9
03-09-2016 08:16 AM
TyroneBiggums
Occasional Contributor III

I have a thing that selects a layer. On map click, I set up some stuff but mostly follow the example on https://developers.arcgis.com/javascript/jssamples/find_popup.html

The layer that I select is where I get the url from for the IdentifyTask. That doesn't work b/c IdentifyTask wants a service url.

Question 1: How do I return the service url from a feature layer?

Question 2: How do I figure out which layer, in the service, that I need for the IdentifyParameters.layerIds array?

Note, if I hard code a service into my code, the IdentityTask call back does return a proper response. I just need the middle goods to finish this.

Thank you

0 Kudos
9 Replies
SteveCole
Frequent Contributor

Untested, but assuming you had a feature layer with a service URL of

"http://<server>/<some folder>/serviceLayerName/MapServer/4"

The answer to #1 be "<feature layer name>.url"

The answer to #2 should just be the number at the end of the URL. In my example, it would be "4". In terms of the URL to provide to the IdentifyTask constructor, you just need to strip the "/4" off of the URL and pass that to the constructor.

0 Kudos
TyroneBiggums
Occasional Contributor III

That's what I started doing... splicing the layer.url at the last "/" and now I have the service URL and the layer id. It just feels dirty.

Is there a decent way of Identifying more than one service at a time? I have a use case for 3 layers on the map from 2 services. I'd have to look at all the urls, splice them all as you described, compare service urls and grab their respective id and create a IdentifyTask for each unique service url? That sounds dirtier.

0 Kudos
SteveCole
Frequent Contributor

Hah, gotcha. I don't know, then. I think the most likely answer is that ESRI never anticipated someone wanted to do that and so using the identifyTask with multiple (and separately published) services isn't supported. This week is the Developer's Conference in Palm Springs so responses from ESRI's side of the equation will be light, at best.

TyroneBiggums
Occasional Contributor III

Is there a way to limit the results returned by the IdentifyTask? I get the results back pretty quick but then I'm creating column headers based on the response.feature.attributes and throwing the data in a json object. Then I'm iteration through the response.feature.attributes to match all of the values to the column. My sample feature service has 1000 features. It's taking a LONG time to build my json object of the data that is returned from response.

0 Kudos
thejuskambi
Occasional Contributor III

If you are building the column headers from the feature.attributes. why are you iterating throught the attributes again.

you could just use array.map and get a list of objects and bind it dgrid. (I guess you are using dgrid or datagrid).

0 Kudos
TyroneBiggums
Occasional Contributor III

I'm using html labels, unordered lists and divs. I'm looping through to get the columns then looping through to tie values to existing columns, throwing that in json and iterating through the json to build html. I may could refactor the looptyloops.

0 Kudos
SteveCole
Frequent Contributor

Limit the results for what? Only for selected attribute fields? Limited by distance?

Are you using something like JSON.stringify to convert the array to JSON? Here's an example.

0 Kudos
TyroneBiggums
Occasional Contributor III

Limit the selected attribute count that is displayed. My tolerance is 3. Given where the data is, I could click on Florida and get 30 results back. I could click on the gulf and get 500. I don't need 500. I would only really need to display about 50 at a time. Is lowering the tolerance what I want?

0 Kudos
KenBuja
MVP Esteemed Contributor

Although it's an old post, take a look at this discussion, which shows how to attach the identifyParameters to the result of an identifyTask

0 Kudos