0
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
  • make sure you're returning the correct value...
    – sfletche
    Apr 25, 2014 at 17:56
  • @sfletche I've tried returning everything under the sun - still the same result. Question. In the line "<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. Apr 25, 2014 at 18:01

2 Answers 2

1

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;
};
2
  • 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..... Apr 25, 2014 at 18:32
  • GOT IT! compare = function (value,key,data) was missing Apr 25, 2014 at 20:35
0

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?

2
  • 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 of data.Tbl_ResultSummary_VQO_HA - data.Tbl_ResultsSummary_VQO_Not_Greened_Up_Ha Does that make sense? Apr 25, 2014 at 18:12
  • Trying to follow the example of developers.arcgis.com/javascript/jshelp/… Second example under return a string Apr 25, 2014 at 18:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.