Arkitech

Two Infowindows

Discussion created by Arkitech on Oct 24, 2012
Hi

I would like to use two info windows, both displaying different results.

One will be for the address search results (once the map zoom's into the location)

//the info window for the address details after zooming to location on map
            function buildAddWindow(addr, pt) {
                var replacement = ", ";
                var addrTrim = addr.replace(/\|LOCATOR_SEPARATOR\|/g, replacement);
                console.log(addrTrim);
                var addInfoTemplate = new esri.InfoTemplate(addrTrim);
  map.infoWindow.setTitle("Address");
                map.infoWindow.setContent("Address : " + addrTrim);
                map.infoWindow.resize(250, 175);
                map.infoWindow.show(pt, esri.dijit.InfoWindow.ANCHOR_LOWERRIGHT);
            };


The other is for the identify results its quite complex so this is just a section of where it creates the info window:

  // identify and retrieve layers from the rest endpoint
  function setUpIdentify(layers) {
   //when user clicks on map, call doIndentify()
   //map.graphics.clear();
   dojo.connect(map, "onClick", doIdentify); 
            console.log("Setting up identify");
   identifyTask = new esri.tasks.IdentifyTask("http://sccw08ags/ArcGIS/rest/services/APILBSR/MapServer");
   identifyParams = new esri.tasks.IdentifyParameters();
   //identifyParams.spatialReference = new esri.SpatialReference({ wkid: 27700});
   identifyParams.tolerance = 5;
   identifyParams.returnGeometry = true;
   identifyParams.layerIds = layers;
   //console.log(layers);
   //identifyParams.layerIds = visible;
   identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL;   
   //create info window
   //var ideninfoTemplate = new esri.InfoTemplate();
   map.infoWindow.resize(480, 300);
   map.infoWindow.setContent(dijit.byId("tabs").domNode);
   map.infoWindow.setTitle("Identify Results");         
  }
  
  
  function doIdentify(evt) {
   console.log("Do Identify");                          
   map.graphics.clear();
   identifyParams.geometry = evt.mapPoint;
   identifyParams.mapExtent = map.extent;

   var mapLevel = map.getLevel();
   if (mapLevel >=7 ) {
    identifyTask.execute(identifyParams, function(idResults) { addToMap(idResults, evt); });
   }else {
    alert("This has returned too many results.\n\nPlease zoom in or search for an address to narrow your selection");
   }
  };
  


I am having issues when once a user has done an address search and the map has zoomed into the location and shown the address details in the info window. If i then click on a item to run the identify task i get an error relating to the following function:

// add results to info window - custom to this application each layer results are manually configured here
  function addToMap(idResults, evt) {
   layer7results = { displayFieldName: null, features: [] };
   layer3results = { displayFieldName: null, features: [] };
   layer4results = { displayFieldName: null, features: [] };
   layer2results = { displayFieldName: null, features: [] };
   layer0results = { displayFieldName: null, features: [] };
   layer1results = { displayFieldName: null, features: [] };
          

   for (var i = 0, il = idResults.length; i < il; i++) {
    var idResult = idResults[i];
    if (idResult.layerId === 7) {      
     if (!layer7results.displayFieldName) { layer7results.displayFieldName = idResult.displayFieldName };
     layer7results.features.push(idResult.feature);
    } else if (idResult.layerId === 3) {
     if (!layer3results.displayFieldName) { layer3results.displayFieldName = idResult.displayFieldName };
     layer3results.features.push(idResult.feature);
    } else if (idResult.layerId === 4) {
     if (!layer4results.displayFieldName) { layer4results.displayFieldName = idResult.displayFieldName };
     layer4results.features.push(idResult.feature);
    } else if (idResult.layerId === 2) {
     if (!layer2results.displayFieldName) { layer2results.displayFieldName = idResult.displayFieldName };
     layer2results.features.push(idResult.feature);
    } else if (idResult.layerId === 0) {
     if (!layer0results.displayFieldName) { layer0results.displayFieldName = idResult.displayFieldName };
     layer0results.features.push(idResult.feature);
    } else if (idResult.layerId === 1) {
     if (!layer1results.displayFieldName) { layer1results.displayFieldName = idResult.displayFieldName };
     layer1results.features.push(idResult.feature);
    }
   }
   dijit.byId("layer7Tab").setContent(layerTabContent(layer7results, "layer7results", evt.mapPoint));
   dijit.byId("layer3Tab").setContent(layerTabContent(layer3results, "layer3results", evt.mapPoint));
   dijit.byId("layer4Tab").setContent(layerTabContent(layer4results, "layer4results", evt.mapPoint));
   dijit.byId("layer2Tab").setContent(layerTabContent(layer2results, "layer2results", evt.mapPoint));
   dijit.byId("layer0Tab").setContent(layerTabContent(layer0results, "layer0results", evt.mapPoint));
   dijit.byId("layer1Tab").setContent(layerTabContent(layer1results, "layer1results", evt.mapPoint));
          
   map.infoWindow.show(evt.screenPoint, map.getInfoWindowAnchor(evt.screenPoint));
  }


I am getting an error that dijit.byId("layer7Tab") is not defined.

Any ideas?

Thanks

Outcomes