the executeIdentifyTask function is fired from either a map click or grid row click.Since the executeIdentifyTask is responsible for identifying/formatting/displaying popups, I'd like to use the existing executeIdentifyTask to display a popup after a grid row click.If a grid click, I want to display the popup, stripping out any close-by identify results that may have been included. If grid click, I lower the identifyParams.tolerance, but I still pickup a few unwanted results around the facility point geometry that was grid-clicked
dojo.connect(grid1, "onRowClick", onRowClickHandler);
dojo.connect(map,"onClick",executeIdentifyTask);
function onRowClickHandler(evt){
var selectedFac;
//other non-pertinent code
map.centerAndZoom(selectedFac.geometry, 15);
executeIdentifyTask(selectedFac);
}
function executeIdentifyTask(evt) {
var lids = []; //array to hold layer id's to identify
var anchorPt; //facility point, substitute for a mouse click
var siteCode; //id for the grid row that was clicked
var j; //index of response object that was grid clicked
var res; //filtered array of response objects
//lets detect if this was fired by a map click or a grid click
if (evt.mapPoint == undefined){
//grid click, only identify the facility point corresponding to the grid row that was clicked i.e. lower identify tolerance
identifyParams.tolerance = 1;
anchorPt = evt.geometry;
siteCode = evt.attributes.site_code;
//set lids to include only facil layer
lids.push(0);
}
identifyParams.layerIds = lids;
var deferred = identifyTask.execute(identifyParams);
deferred.addCallback(function(response) {
if (!(siteCode == undefined)){
for (var i in response){
var fac = response;
if (fac.feature.attributes.site_code == siteCode){
j = i;
break;
}
}
res = response;
}
else{
//no filtering the identify response; this was fired by map click
res = response;
}
return dojo.map(res, function(result) {
//if res is set to response, script never gets here, ends at break above <----problem
var feature = result.feature;
//esri.dijit.PopupTemplate's set here
return feature;
}
})
}
any advice would be great! Thanks.