Select to view content in your preferred language

How to make attributes without values not to be shown?

2372
3
01-20-2016 01:21 AM
NedimNasic_Kjellgren
New Contributor

Hello!

I´m going to explain question a bit further.

I made a side bar where I´m showing all my content from pop up (which is turned off). We chose few of attributes we want to show within the sidebar, but the problem is that not all features have values under all those attributes, so now they are just shown as empty.

Bigger problem are the links, since we have 2 attributes showing links to external documents (with clickable text "More info").

Now, no matter if there is a link in the table for that feature or not, both link attributes are shown, both with clickable text, from which only one is right or none (as some don´t have any external links).

I would like a solution where I can write in the code, if attribute is without value not to be shown, those ones with values to be shown. I´ve tried with different combinations of IF ELSE, but didn´t work, I just lack experience.

Here´s the part of the code with attributes in JS:

var other = new InfoTemplate("",
  // OTHER ATTRIBUTES
  " <b>Name</b>:<br> ${Name}" + "<br>" + "<br>" +
  "&nbsp<b>Map layer</b>:<br> ${Map_layer}"+ "<br>" + "<br>" +
  "&nbsp<b>Classification</b>:<br> ${Classification}"+ "<br>" + "<br>" +
  "&nbsp<b>Assesment</b>:<br> ${Assesment}" + "<br>" + "<br>" +
  " <b>Justification</b>:<br> ${Justification}" + "<br>" + "<br>" +
  " <b>Link</b>:<br> <a href=${Link} target=_blank>More info</a>" + "<br>" + "<br>" +
  " <b>Link2</b>:<br> <a href=${Link2} target=_blank>More info</a>" + "<br>" + "<br>" +
  "&nbsp<b>Contact person</b>:<br> ${Contact_person}"

   );

Help is much appreciated! Thanks!

0 Kudos
3 Replies
KousikM
Occasional Contributor

Nedim,

I think you may get attribute values using IdentifyTask. When you execute the IdentifyTask, you will get results if there is any feature on map . Then you can check your attribute values are empty or not.

For example,

var feature = result.feature;

if(feature.attributes["Link"] === Null);

See this sample Display identify results in popup | ArcGIS API for JavaScript

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Nedim,

   I would look into using the infoTemplates setContent​method then as you can manipulate the data and define what is to be shown in the pop-up before it is shown. There are sveral examples of using this method if you search for setContent.

0 Kudos
NedimNasic_Kjellgren
New Contributor

I´ll study it a bit closer one of these days and see how it´ll go for me.

Thanks to both!

0 Kudos