HiI am trying to implement a toolbar with identify and draw functions initially on it but am having some problems.When I activate the identify tool for the first time it works fine, but if I were to change to the draw tool then back to the identify tool, my infowindow does not pop up, firebug gives me the following message:-TypeError: Cannot call method 'setContent' of undefined{...}There appears to be an issue specifically with how I am setting my content to show but am not too sure why it would initially work, then fail on the next call.Can anyone see any problems with the below code? I am just including how the tool is activated and the identify function so if other bits are required I can post these up.Many thanks!//CODE TO SET THE DIFFERENT TOOLSfunction turnidTool(ident) { idTool = ident; if (idTool==0) { if (drawHandle!=null) { dojo.disconnect(drawHandle); drawHandle = null; } if (identifyHandle!=null) { dojo.disconnect(identifyHandle); resetFunctionality(); identifyHandle = null; } } if (idTool==1) { if (drawHandle!=null) { dojo.disconnect(drawHandle); drawHandle = null; } if (identifyHandle==null) { identifyHandle = dojo.connect(map, "onClick", doIdentify); } } if (idTool==2) { if (identifyHandle!=null) { dojo.disconnect(identifyHandle); resetFunctionality(); identifyHandle = null; } if (drawHandle==null) { drawHandle = dojo.connect(map, "onClick", doDraw); } } }//CODE FOR THE IDENTIFY TOOL function resetFunctionality() { identifyTask = null; identifyParams = null; symbol = null; } function initFunctionality(map) { if (drawHandle!=null) { dojo.disconnect(drawHandle); drawHandle = null; } identifyTask = new esri.tasks.IdentifyTask("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer"); identifyParams = new esri.tasks.IdentifyParameters(); identifyParams.tolerance = 3; identifyParams.returnGeometry = true; identifyParams.layerIds = [0,2]; identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL; identifyParams.width = map.width; identifyParams.height = map.height; map.infoWindow.resize(400, 250); map.infoWindow.setContent(dijit.byId("tabs").domNode); map.infoWindow.setTitle("Identify Results"); symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,0,0]), 2), new dojo.Color([255,255,0,0.25])); } function doIdentify(evt) { if (identifyParams==null) { initFunctionality(map); } map.graphics.clear(); identifyParams.geometry = evt.mapPoint; identifyParams.mapExtent = map.extent; identifyTask.execute(identifyParams, function(idResults) { addToMap(idResults, evt); }); } function addToMap(idResults, evt) { bldgResults = {displayFieldName:null,features:[]}; parcelResults = {displayFieldName:null,features:[]}; for (var i=0, il=idResults.length; i<il; i++) { var idResult = idResults; if (idResult.layerId === 0) { if (!bldgResults.displayFieldName) {bldgResults.displayFieldName = idResult.displayFieldName}; bldgResults.features.push(idResult.feature); } else if (idResult.layerId === 2) { if (!parcelResults.displayFieldName) {parcelResults.displayFieldName = idResult.displayFieldName}; parcelResults.features.push(idResult.feature); } } dijit.byId("bldgTab").setContent(layerTabContent(bldgResults,"bldgResults")); dijit.byId("parcelTab").setContent(layerTabContent(parcelResults,"parcelResults")); map.infoWindow.show(evt.screenPoint, map.getInfoWindowAnchor(evt.screenPoint)); } function layerTabContent(layerResults, layerName) { var content = ""; switch (layerName) { case "bldgResults": if (bldgResults.features.length !== 0){ content = "<b>Building Footprints</b></br>"; content += "<i>Total features returned: " + layerResults.features.length + "</i>"; content += "<table border='1'><tr><th>ID</th><th>Address</th></tr>"; for (var i=0, il=layerResults.features.length; i<il; i++) { content+="<tr><td>"+layerResults.features.attributes['PARCELID']+" <a href='#' onclick='showFeature(" + layerName + ".features[" + i + "]); return false;'>(show)</a></td>"; content+="<td>"+layerResults.features.attributes['Full Site Address']+"</td>"; } content+="</tr></table>"; } break; case "parcelResults": if (parcelResults.features.length !== 0){ content = "<b>Tax Parcels</b></br>"; content += "<i>Total features returned: " + layerResults.features.length + "</i>"; content += "<table border='1'><tr><th>ID</th><th>Year Built</th><th>School District</th><th>Description</th></tr>"; for (var i=0, il=layerResults.features.length; i<il; i++) { content+="<tr><td>"+layerResults.features.attributes['Parcel Identification Number']+" <a href='#' onclick='showFeature(" + layerName + ".features[" + i + "]); return false;'>(show)</a></td>"; content+="<td>"+layerResults.features.attributes['Residential Year Built']+"</td>"; content+="<td>"+layerResults.features.attributes['School District Description']+"</td>"; content+="<td>"+layerResults.features.attributes['Property Description']+"</td>"; } content+="</tr></table>"; } break; } return content; }
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.