Hi all,I have this small piece of code which should switch between two feature layers (mode set as 'MODE_ONDEMAND') and display one depending on the selection. Once displayed, it should also show the infoWindow. Though it is a small piece of code, I believe I am missing something because of which it keeps giving me errors. Here is the code:function queryParam(indc, indValue, flag, geog) { //indc=Indicator, indValue=indicator value, flag returns 'true' or 'false' depending on unit of analysis, geog is the selected State of India using a pull down menu
query = new esri.tasks.Query();
query.returnGeometry = true;
query.outFields = ["*"];
query.where = "1=1";
var resultContent = "<tr>" + indc + ": <td>${" + indValue + ":formatNumber}</td></tr>";
var renderer = new esri.renderer.ClassBreaksRenderer(symbol, indValue);
renderer.addBreak(0.01, 19, symbolSet31);
renderer.addBreak(19, 27, symbolSet32);
renderer.addBreak(27, Infinity, symbolSet33);
if (flag === true) {
infoTemplate.setTitle("<tr>State: <td>${State_name}</tr></td>");
stateFeatureLayer.setRenderer(renderer);
mapM.addLayer(stateFeatureLayer);
} else if (flag === false) {
infoTemplate.setTitle("<tr>DISTRICT: <td>${Dist_name}</tr></td><br /><tr>STATE: <td>${State_name}</tr></td>");
distFeatureLayer.setRenderer(renderer);
if (geog != "All India") { //if a single State is selected. the code selects districts (sub-State) to display within the selected State
distFeatureLayer.setDefinitionExpression("State_name= '" + geog + "'");
distFeatureLayer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW);
dojo.connect(distFeatureLayer, "onSelectionComplete", mapM.addLayer(distFeatureLayer));
} else if (geog == "All India") { //if "All India" is selected using the pull down menu. This displays all districts in the country
distFeatureLayer.clearSelection();
mapM.addLayer(distFeatureLayer);
}
}
infoTemplate.setContent(resultContent);
}
I get the following errors, primarily when flag==false:- The first State selected works well but shows a 'type error' in the web console. Changing geog from one state to another displays the features of the next State but does not bring up the infoWindow when clicked on the map. This shows a 'type error' too.
- Selecting "All India" does not remove the previous selection and does not display all features.
Please see if you can test this code using your data. I'll be happy to provide the underlying html document.ThanksSamir