Is identifyTask dependent on current extent?

787
10
06-30-2011 03:17 PM
PerryDonnafield
New Contributor
What I am finding out is that the identifyTask does not return results once my scale reaches a certain point. At large scales it works fine. At small scales past about 50,000 it no longer works.

My spatial reference is webmercator(102100) if that helps, and the layer I am trying to identify on has a min scale set at 72225. So, it would seem that after 72225 it would no longer work but should work up until then.

I am using esri.geometry.getScale to determine the scale and I assume that the scale returned is correct.

Anyone have any ideas? Thanks.

Here is my identify code:
cadastral.identifyTask = new esri.tasks.IdentifyTask(mapUrl);

  cadastral.identifyParams = new esri.tasks.IdentifyParameters();
  cadastral.identifyParams.tolerance = 0;
  cadastral.identifyParams.returnGeometry = true;
  var identifyArray = [9];
  cadastral.identifyParams.layerIds = identifyArray;
  cadastral.identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE; //.LAYER_OPTION_ALL;
  cadastral.identifyParams.geometry = evt.mapPoint;
  cadastral.identifyParams.mapExtent = cadastral.map.extent;
  cadastral.identifyTask.execute(cadastral.identifyParams, function (idResults) { cadastral.identify.setupIdentifyResults(idResults, evt); }, function (idResults) { cadastral.showError(idResults, evt); });
0 Kudos
10 Replies
HemingZhu
Occasional Contributor III
What I am finding out is that the identifyTask does not return results once my scale reaches a certain point. At large scales it works fine. At small scales past about 50,000 it no longer works.

My spatial reference is webmercator(102100) if that helps, and the layer I am trying to identify on has a min scale set at 72225. So, it would seem that after 72225 it would no longer work but should work up until then.

I am using esri.geometry.getScale to determine the scale and I assume that the scale returned is correct.

Anyone have any ideas? Thanks.

Here is my identify code:
cadastral.identifyTask = new esri.tasks.IdentifyTask(mapUrl);

  cadastral.identifyParams = new esri.tasks.IdentifyParameters();
  cadastral.identifyParams.tolerance = 0;
  cadastral.identifyParams.returnGeometry = true;
  var identifyArray = [9];
  cadastral.identifyParams.layerIds = identifyArray;
  cadastral.identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE; //.LAYER_OPTION_ALL;
  cadastral.identifyParams.geometry = evt.mapPoint;
  cadastral.identifyParams.mapExtent = cadastral.map.extent;
  cadastral.identifyTask.execute(cadastral.identifyParams, function (idResults) { cadastral.identify.setupIdentifyResults(idResults, evt); }, function (idResults) { cadastral.showError(idResults, evt); });


Usually map.mapExtent, map.height and map.width along with tolerance are used in identifyParameters to determine the search distance and visible layers. I would change the code a little bit and test it again. Suggested code:
cadastral.identifyTask = new esri.tasks.IdentifyTask(mapUrl);
cadastral.identifyParams = new esri.tasks.IdentifyParameters();
cadastral.identifyParams.tolerance = 1; // unless you identify a polygon layer, always give tolerance some positive value.
cadastral.identifyParams.returnGeometry = true;
cadastral.identifyParams.layerIds = [9];
cadastral.identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL; //just make sure your layer 9 is always in your identify list
cadastral.identifyParams.geometry = evt.mapPoint;
cadastral.identifyParams.mapExtent = cadastral.map.extent;
cadastral.identifyParams.height = cadastral.map.height;
cadastral.identifyParams.width = cadastral.map.width;
......

Good luck
0 Kudos
PerryDonnafield
New Contributor
This is what I ended up with. I think height and width were the key.
cadastral.identifyTask = new esri.tasks.IdentifyTask(mapUrl);
cadastral.identifyParams = new esri.tasks.IdentifyParameters();
cadastral.identifyParams.tolerance = 0;
cadastral.identifyParams.returnGeometry = true;
cadastral.identifyParams.layerIds = [9];
cadastral.identifyParams.geometry = evt.mapPoint;
cadastral.identifyParams.mapExtent = cadastral.map.extent;
cadastral.identifyParams.height = cadastral.map.height;
cadastral.identifyParams.width = cadastral.map.width;


Since I am identifying on a polygon layer, what should the tolerance be? I just figured 0 would be best for a polygon.

Thanks for the help.
0 Kudos
HemingZhu
Occasional Contributor III
This is what I ended up with. I think height and width were the key.
cadastral.identifyTask = new esri.tasks.IdentifyTask(mapUrl);
cadastral.identifyParams = new esri.tasks.IdentifyParameters();
cadastral.identifyParams.tolerance = 0;
cadastral.identifyParams.returnGeometry = true;
cadastral.identifyParams.layerIds = [9];
cadastral.identifyParams.geometry = evt.mapPoint;
cadastral.identifyParams.mapExtent = cadastral.map.extent;
cadastral.identifyParams.height = cadastral.map.height;
cadastral.identifyParams.width = cadastral.map.width;


Since I am identifying on a polygon layer, what should the tolerance be? I just figured 0 would be best for a polygon.

Thanks for the help.


tolerance is usually used for point geometry. I guess 0 would be OK for polygon.
0 Kudos
AndyStewart1
New Contributor III
I'm experiencing a similar issue.  I have a map service with some layers visible at all extents, while other layers are visible only below 1000 ft.  For the layers that are always visible, my click event triggers the identifyTask every time and I get the results I want.  When I get to 1000 ft, I can see the other layers, but the click event doesn't return objects until after I zoom in a couple of more levels.  My assumption is that if I can see the features, I can identify them.  But that's not the case.

I don't see any real differences in my code vs. the other code examples in this thread.  Any suggestions?
0 Kudos
JeffPace
MVP Alum
I'm experiencing a similar issue.  I have a map service with some layers visible at all extents, while other layers are visible only below 1000 ft.  For the layers that are always visible, my click event triggers the identifyTask every time and I get the results I want.  When I get to 1000 ft, I can see the other layers, but the click event doesn't return objects until after I zoom in a couple of more levels.  My assumption is that if I can see the features, I can identify them.  But that's not the case.

I don't see any real differences in my code vs. the other code examples in this thread.  Any suggestions?


Remember the default is to return only the top layer.

identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_TOP;

if you want all its

identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL;

or visibile

identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE;

if you dont explicitly set it, it is TOP.
0 Kudos
AndyStewart1
New Contributor III
Right.  And right now we're using:
identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE;

So it makes me wonder why I can't detect certain items in the same service when they first become visible....
0 Kudos
JeffPace
MVP Alum
Right.  And right now we're using:
identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE;

So it makes me wonder why I can't detect certain items in the same service when they first become visible....


IS your rest service publicly accessible?


It looks like you are only identifying layer 9, and then only if its visible.  Is that correct?
0 Kudos
AndyStewart1
New Contributor III
We're identifying all the layers. (The layer 9 was the original poster's code).

Here's a more complete look at what I have:

 identifyTask = new esri.tasks.IdentifyTask(MyESRISearchUrl);
        identifyParams = new esri.tasks.IdentifyParameters();
 identifyParams.tolerance = 2;
 identifyParams.returnGeometry = true;
 var lids = "";
 identifyParams.layerIds = MyESRILayerIDs;
 lids += " --- ";
 identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE; /* LAYER_OPTION_TOP; */


I swapped out LAYER_OPTION_VISIBLE for LAYER_OPTION_ALL and that of course enabled me to see everything.  But I need to find a way to get LAYER_OPTION_VISIBLE working properly (assuming that when anything is visible on the map, I can identify it).

We did have some permission issues early on with the service--I believe it's accessible now.  How could the REST API not being publicly accessible make some layers visible/identifiable and some not?
0 Kudos
JeffPace
MVP Alum
We're identifying all the layers. (The layer 9 was the original poster's code).

Here's a more complete look at what I have:

 identifyTask = new esri.tasks.IdentifyTask(MyESRISearchUrl);
        identifyParams = new esri.tasks.IdentifyParameters();
 identifyParams.tolerance = 2;
 identifyParams.returnGeometry = true;
 var lids = "";
 identifyParams.layerIds = MyESRILayerIDs;
 lids += " --- ";
 identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE; /* LAYER_OPTION_TOP; */


I swapped out LAYER_OPTION_VISIBLE for LAYER_OPTION_ALL and that of course enabled me to see everything.  But I need to find a way to get LAYER_OPTION_VISIBLE working properly (assuming that when anything is visible on the map, I can identify it).

We did have some permission issues early on with the service--I believe it's accessible now.  How could the REST API not being publicly accessible make some layers visible/identifiable and some not?


Public accessibility wouldn't affect function, but it would allow me to see it to try to help 🙂
0 Kudos