doIdentify = function(evt) { // Hide the previous results myMap.infoWindow.hide(); var task = null; var params = null; task = new esri.tasks.IdentifyTask(url.baseMap); params = new esri.tasks.IdentifyParameters(); params.tolerance = 4; params.returnGeometry = true; params.layerIds = [3, 4, 5, 6]; params.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL; params.width = myMap.width; params.height = myMap.height; params.geometry = evt.mapPoint; params.mapExtent = myMap.extent; task.execute(params, function(idResults) { identifyInfoWin(idResults, evt); }, function(err) { console.log("doIdentify: (" + err.name + ") " + err.message); }); };
When I try to identify a feature, the IdentifyTask's execute function is invoking an error that simply contains the message "Unable to complete operation."
The strange thing is, this identify function works as it should when I use it at either the map's full extent or a specific extent of a feature (when I zoom to a feature via the results in a Datagrid), but once I pan the map even slightly out of that specific extent, the IdentifyTask throws that error.
My code is listed in the following. It's a loose interpretation of the "Identify features on a map" sample provided by ArcGIS.doIdentify = function(evt) { // Hide the previous results myMap.infoWindow.hide(); var task = null; var params = null; task = new esri.tasks.IdentifyTask(url.baseMap); params = new esri.tasks.IdentifyParameters(); params.tolerance = 4; params.returnGeometry = true; params.layerIds = [3, 4, 5, 6]; params.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL; params.width = myMap.width; params.height = myMap.height; params.geometry = evt.mapPoint; params.mapExtent = myMap.extent; task.execute(params, function(idResults) { identifyInfoWin(idResults, evt); }, function(err) { console.log("doIdentify: (" + err.name + ") " + err.message); }); };
I consider myself well-acquainted with the ArcGIS JS API, but I have been staring at this problem for much too long without seeking help.
Thanks in advance
Take out this optional function function(err) from your code and try again. Believe it or not sometime this function do harm that it do good.
task.execute(params); dojo.connect(task, "onComplete", function(idResults) { identifyInfoWin(idResults, evt); // Hide the loading bar when a result is found }); dojo.connect(task, "onError", function(err) { console.log("doIdentify: (" + err.name + ") " + err.message); });
// This is entirely the WRONG way to declare an extent var startExtent = new esri.geometry.Extent({ xmin: -107.62971356312966, ymin: 25.850355124455604, xmax: -92.35392362656452, ymax: 36.59093275985384, spatialReference: { wkid: "4269" } }); myMap = new esri.Map("mapDiv", { extent: startExtent, logo: false, slider: false });
startExtent = new esri.geometry.Extent(-101.120185812004, 34.39538449192201, -100.983017186634, 34.49182927651549, new esri.SpatialReference({ wkid: 4269 }));