var vliTemplate = new InfoTemplate("Visual", "<tr><b>VLI Number:</b> <td>${VLI_VLI_NO} </tr></td>"+
"<br><tr><b>Not Greened Up CFLB:</b><td>${Tbl_ResultSummary_VQO_Not_Greened_Up_Ha:NumberFormat(places:0)} Ha</tr></td>"+
"<br><tr>Greened Up CFLB:<td>${greened:compare} Ha</tr></td>"+
"<br><tr><b>Maximum Target Percent:</b><td>${Tbl_ResultSummary_VQO_Pct_tgt:NumberFormat(places:0)}%</tr></td>"+
"<br><tr><b>Maximum Target:</b><td>${Tbl_ResultSummary_VQO_Target_Ha:NumberFormat(places:0)} Ha</tr></td>")
compare = function (key) {
var result = diff;
switch (key) {
case "greened":
diff = data.Tbl_ResultSummary_VQO_HA - data.Tbl_ResultsSummary_VQO_Not_Greened_Up_Ha;
break;
}
return result;
};
I've been playing around with the code in my switch case function trying to get wording or placements of words to work for me, but I can't seem to get my popup to display anymore. In the popup, I want the line "Greened up CFLB" to show the calculation of Tbl_ResultSummary_VQO_HA - Tbl_ResultsSummary_VQO_Not_Greened_Up_Ha but now the popup won't even display (because I know I'm not writing my fucntion/switch statement correctly)
Can someone please provide feedback on where I'm going wrong in my code? I know its a simple case of not having the right things in the right place...but I'm at a loss.
Thanks!
2 Answers 2
Try this instead:
compare = function (key) {
var result = "", diff;
switch (key) {
case "greened":
diff = data.Tbl_ResultSummary_VQO_HA - data.Tbl_ResultsSummary_VQO_Not_Greened_Up_Ha;
break;
}
result = diff;
return result;
};
-
Well that gets me one step further!! My popup's are now showing up again, but the calculation is not working....but it gets me further than I have been.....InsaneBunny– InsaneBunny2014年04月25日 18:32:30 +00:00Commented Apr 25, 2014 at 18:32
-
GOT IT!
compare = function (value,key,data)
was missingInsaneBunny– InsaneBunny2014年04月25日 20:35:16 +00:00Commented Apr 25, 2014 at 20:35
I would put this as a comment but I don't have enough rep. I can't really tell what you're trying to accomplish with your switch statement. You assign result to diff, and then assign diff based upon the switch statement and return result. So the switch statement has no effect on the return value. Do you mean to put the line
var result = diff;
after the switch statement, just before your return statement?
-
At this point my code is a mess of things that I've tried, I don't even know what would be right anymore. The end result is a popup in my map window when I click on a polygon feature. in my
"<br><tr>Greened Up CFLB:<td>${greened:compare} Ha</tr></td>"+
line, the switch statement is basically to change the greened:compare to be the result of diff which is the calculation ofdata.Tbl_ResultSummary_VQO_HA - data.Tbl_ResultsSummary_VQO_Not_Greened_Up_Ha
Does that make sense?InsaneBunny– InsaneBunny2014年04月25日 18:12:57 +00:00Commented Apr 25, 2014 at 18:12 -
Trying to follow the example of developers.arcgis.com/javascript/jshelp/… Second example under return a stringInsaneBunny– InsaneBunny2014年04月25日 18:18:08 +00:00Commented Apr 25, 2014 at 18:18
Explore related questions
See similar questions with these tags.
"<br><tr>Greened Up CFLB:<td>${greened:compare} Ha</tr></td>"+
Where I say greened:compare - greened is not actually the name of any attribute that I have, I just created a name to put in there. Does this need to be one of my attributes that I'm using? Very new at js and been trying to work through this problem for a while. Thanks.