Identify task on multiple dynamic map services

4522
4
Jump to solution
05-08-2012 12:36 PM
LuciHawkins
Occasional Contributor III
I would like to know if it is possible to click on the map, it searches 5px and returns all the items in that vicinity even if they are on different dynamic map service layers.  We are currently using an enhanced identify widget in our Flex app but would like to know if it is possible in our HTML5 version that we are working on.

I have successfully setup the identify task sample to use one of my dynamic map services to return an infoWindow if an item is on one of its layers and within a certain distance of the mouse click.  So I have a basic understanding of the javascript version.   I would just like it to apply to all dynamic map services instead of just one.

Thanks,

Luci
0 Kudos
1 Solution

Accepted Solutions
danbecker
Occasional Contributor III
i think this is what your looking for

hxxp://gis.stackexchange.com/questions/12407/how-to-identify-layers-from-multiple-arcgis-server-instances

View solution in original post

0 Kudos
4 Replies
danbecker
Occasional Contributor III
i think this is what your looking for

hxxp://gis.stackexchange.com/questions/12407/how-to-identify-layers-from-multiple-arcgis-server-instances
0 Kudos
evanpicard
New Contributor II
here's what im doing to do an identify on 2 layers - one is a dynamic layer that needs to be updated every 2 weeks, the other is a pretty static cached layer.
im pretty sure the params could get included in the executeIdentityTask function:

it works like this :
if there is a sales rep point (the dynamic layer), it identifies that, and a popup executes
if there's no sales rep, it gets all the info from any visible layer from the cached layer.

Good luck.



      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);      
      };
      
0 Kudos
LuciHawkins
Occasional Contributor III
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
0 Kudos
jerrysalinas
New Contributor
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


Hi,
In using the above example and Identify tool, is there a way to tweak the code to not display a field if it is null. If it is null, I just want to display a blank attribute versus seeing the text "null"

Thanks.
0 Kudos