Solved! Go to Solution.
function mapReady(map){
dojo.connect(map,"onClick",executeIdentifyTask);
//create identify tasks and setup parameters
identifyTaskCombined = new esri.tasks.IdentifyTask("http://server/ArcGIS/rest/services/combined/MapServer/");
identifyTaskReps = new esri.tasks.IdentifyTask("http://server/ArcGIS/rest/services/IndivTerritoriesOnly/SalesReps_simple/MapServer/");
identifyParamsCombined = new esri.tasks.IdentifyParameters();
identifyParamsCombined.tolerance = 7;
identifyParamsCombined.returnGeometry = true;
identifyParamsCombined.layerIds = [7,8,9];
identifyParamsCombined.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE;
identifyParamsCombined.width = map.width;
identifyParamsCombined.height = map.height;
identifyParamsReps = new esri.tasks.IdentifyParameters();
identifyParamsReps.tolerance = 15;
identifyParamsReps.returnGeometry = true;
identifyParamsReps.layerIds = [0];
identifyParamsReps.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE;
identifyParamsReps.width = map.width;
identifyParamsReps.height = map.height;
//resize the map when the browser resizes
dojo.connect(dijit.byId('map'), 'resize', map,map.resize);
};
function executeIdentifyTask(evt){
identifyParamsReps.geometry = evt.mapPoint;
identifyParamsReps.mapExtent = map.extent;
var deferred = identifyTaskReps.execute(identifyParamsReps);
deferred.addCallback(function(response){
if (response.length > 0) {
// console.log(response.length)
// response is an array of identify result objects
// Let's return an array of features.
return dojo.map(response, function(result){
var feature = result.feature;
feature.attributes.layerName = result.layerName;
var template = new esri.InfoTemplate("", "${NAME} <br/> Rep #: ${rep_no} <br/> YTD Net Sales: $ ${YTD_Netsales} <br/> Presidents Club: ${PCText} <br/> Leadership: ${Ldr_type}");
feature.setInfoTemplate(template);
return feature;
});
}
else {
identifyParamsCombined.geometry = evt.mapPoint;
identifyParamsCombined.mapExtent = map.extent;
var deferred = identifyTaskCombined.execute(identifyParamsCombined);
deferred.addCallback(function(response){
// response is an array of identify result objects
// Let's return an array of features.
return dojo.map(response, function(result){
var feature = result.feature;
feature.attributes.layerName = result.layerName;
switch (result.layerName) {
case 'Zip Codes':
var template = new esri.InfoTemplate("", "${ZipText} <br/> City: ${Name}<br/> State: ${State}"); //booger
feature.setInfoTemplate(template);
break;
case 'Districts':
var template = new esri.InfoTemplate("", "District: ${new_dist} <br/> District Name: ${new_distname}");
feature.setInfoTemplate(template);
break;
case 'Divisions':
var template = new esri.InfoTemplate("", "Division: ${new_divcode}");
feature.setInfoTemplate(template);
break;
};
return feature;
});
});
};
map.infoWindow.setFeatures([deferred]);
map.infoWindow.show(evt.mapPoint);
});
map.infoWindow.setFeatures([deferred]);
map.infoWindow.show(evt.mapPoint);
};
dbecker88, I followed an URL on the gis.stackexchange website you quoted - http://jsfiddle.net/blordcastillo/mULcz/ - to be specific. The code was easily adaptable to my needs!
Thanks,
Luci