I am having an issue selecting features in my web map for an IdentifyTask operation. I have a dynamic map service that contains a few sublayers that I would like to be able to click and have a popup or infowindow display the attribution for the selected feature. Currently onclick of the "map", the IdentifyTask execution fires off. The problem is that the precision of the map click seems to be off. When I click a feature with the cursor, the feature is not selected and the InfoWindow displays 'No Results' way below where I clicked the cursor. The InfoWindow typically is supposed to display where a user clicks the cursor right? I have to click above the intended feature in order to actually select the feature and have the IdentifyTask recognize it. Its weird. I played around with the tolerance values for the IdentifyParameters object but no luck. Has anybody ever had a similar issue? Is there a way to specify the precision for a mapClick event? Any help would be greatly appreciated. Below is the code I'm using to show the results of the IdentifyTask.
//Create IdentifyTask object
userConfig.identifyTask = new esri.tasks.IdentifyTask(currentServiceUrl);
//Create and setup IdentifyParameters
userConfig.identifyParams = new esri.tasks.IdentifyParameters();
userConfig.identifyParams.height = userConfig.map.height;
userConfig.identifyParams.width = userConfig.map.width;
userConfig.identifyParams.mapExtent = userConfig.map.extent;
userConfig.identifyParams.tolerance = 3;
userConfig.identifyParams.returnGeometry = true;
//Define the layers to identify
var layersToId = [];
if (currentUtilId == "barksdale") {
var layers = userConfig.barksdaleService.visibleLayers;
for (var i = 0; i < layers.length; i++) {
if (layers[i] != 27 && layers[i] != 40 && layers[i] != 82) {
layersToId.push(layers[i]);
}
} //End loop
}
else if (currentUtilId == "malmstrom") {
var layers = userConfig.malmstromService.visibleLayers;
for (var i = 0; i < layers.length; i++) {
if (layers[i] != 27 && layers[i] != 40 && layers[i] != 82) {
layersToId.push(layers[i]);
}
} //End loop
}
else if (currentUtilId == "minot") {
var layers = userConfig.minotService.visibleLayers;
for (var i = 0; i < layers.length; i++) {
if (layers[i] != 27 && layers[i] != 40 && layers[i] != 82) {
layersToId.push(layers[i]);
}
} //End loop
}
else if (currentUtilId == "whiteman") {
var layers = userConfig.whitemanService.visibleLayers;
for (var i = 0; i < layers.length; i++) {
if (layers[i] != 27 && layers[i] != 40 && layers[i] != 82) {
layersToId.push(layers[i]);
}
} //End loop
}
else if (currentUtilId == "warren") {
var layers = userConfig.warrenService.visibleLayers;
for (var i = 0; i < layers.length; i++) {
if (layers[i] != 27 && layers[i] != 40 && layers[i] != 82) {
layersToId.push(layers[i]);
}
} //End loop
}
userConfig.identifyParams.layerIds = layersToId;
userConfig.identifyParams.geometry = evt.mapPoint;
var deferred = userConfig.identifyTask.execute(userConfig.identifyParams);
deferred.addCallback(function (response) {
// Response is array of identify result objects
// Return an array of features.
return dojo.map(response, function (result) {
var feature = result.feature;
var attribution = feature.attributes;
var infoTemplate = new esri.InfoTemplate();
var templateString = "";
//Parse and print the key-value pairs in the attribution object
for (prop in attribution) {
templateString = templateString + "<b>" + prop + "</b>: " + attribution[prop] + "<br>";
}
infoTemplate.setTitle("Identify Results");
infoTemplate.setContent(templateString);
feature.setInfoTemplate(infoTemplate);
return feature;
});
});
userConfig.map.infoWindow.setFeatures([deferred]);
userConfig.map.infoWindow.show(evt.mapPoint);