Select to view content in your preferred language

Type error on point identify

724
1
10-10-2012 04:55 AM
evanpicard
Emerging Contributor
I have a function to do an identify on a point layer.
If the point has a particular attribute, (repLeader != 'N' or 'D'), I need a button added to the popup.

I want it to create an array of all the points within the the identify tolerance, and the popup gives the option to scroll through all the points.
It works, but the problem is, I get a "Type Error".

If I comment out
map.infoWindow.setFeatures([deferred]); 


It works fine for a single point, but I need the option to scroll through the multiple points.


function mapready(map){
       dojo.connect(map, "onClick", executeIdentifyTask);
       identifyTaskReps = new esri.tasks.IdentifyTask(serverVar + salesRepURL);

       identifyParamsReps = new esri.tasks.IdentifyParameters();
       identifyParamsReps.tolerance = 10;
       identifyParamsReps.returnGeometry = true;
       identifyParamsReps.layerIds = [0];
       identifyParamsReps.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE;
       identifyParamsReps.width  = map.width;
       identifyParamsReps.height = map.height;
};


      function executeIdentifyTask(evt){
         identifyParamsReps.geometry = evt.mapPoint;
         identifyParamsReps.mapExtent = map.extent;
         var deferred = identifyTaskReps.execute(identifyParamsReps);
         deferred.addCallback(function(response){
           if (response.length > 0) {
             //         response is an array of identify result objects    
            //         return an array of features.
            return dojo.map(response, function(result){
              var feature = result.feature;
              var repNumber = feature.attributes.rep_no;
              var repName = feature.attributes.NAME;
              var repAddress = feature.attributes.ADDR1;
              var repCity = feature.attributes.CITY;
              var repState = feature.attributes.ST_ABBR;
              var repZip = feature.attributes.ZIP_CODE;
              var repLeader = feature.attributes.Ldr_type;
              var repPrez = feature.attributes.PC_TAG;
              if (repLeader == 'N' || repLeader == 'D') {
                 var content = "<b>Rep # : </b>" + repNumber + "<b><br>Name : </b>" + repName + "<br><b>Address : </b>" + repAddress + "<br><b>City : </b>" + repCity + "<br><b>State : </b>" + repState + "<br><b>Zip : </b>" + repZip + "<br><b> Leader : </b>" + repLeader + "<br><b>Presidents Club :</b>" + repPrez;
              }
              else {
                 var content = "<b>Rep # : </b>" + repNumber + "<b><br>Name : </b>" + repName + "<br><b>Address : </b>" + repAddress + "<br><b>City : </b>" + repCity + "<br><b>State : </b>" + repState + "<br><b>Zip : </b>" + repZip  + "<br><b> Leader : </b>" + repLeader + "<br><b>Presidents Club :</b>" + repPrez + "<br> <button onclick=queryDownLine(" + repNumber + ")>View DownLine</button>"; 
              };     
              map.infoWindow.setTitle(repName);
              map.infoWindow.setContent(content);
            });
          }
        }); //end of reps
        map.infoWindow.setFeatures([deferred]);    //sales reps  //IF I COMMENT OUT THIS LINE
        map.infoWindow.show(evt.mapPoint);         //sales reps
      }; //end of function
0 Kudos
1 Reply
evanpicard
Emerging Contributor
Ummmm, help please?
0 Kudos