AnsweredAssumed Answered

Dynamically change the infotemplate on a feature layer

Question asked by JALevine on Jan 29, 2016
Latest reply on Jan 29, 2016 by schlot

I have a feature layer that I've constructed from a url, and have applied a feature template to it to display a popup when a feature is clicked.  I also have a feature layer that I've constructed from a feature collection object (not a url) that I have applied a separate infotemplate to.  For the latter, the infotemplate displays data in a popup window for, let's say, fields X, Y, and Z; this looks something like: featureLayer.setInfoTemplate(new InfoTemplate('$X','Name: $Y <br/>Type: $Z'));  This displays a popup where the value for X is displayed as the title, and the contents are values for Y and Z.  However, sometimes the value for Y is an empty string, and when this occurs, I'd like to not display field Y in my popup.  How can I check for the value of Y when the feature is clicked so that I can dynamically alter the infotemplate to not show Y if it is an empty string?

 

Thanks,

Jason

Outcomes