Select to view content in your preferred language

PopupTemplate for MapImageLayer from REST: how to access value of field {fieldname} for simple analysis?

352
0
10-13-2022 06:49 AM
nadja
by
Frequent Contributor

We're using a MapImageLayer with a popup, which is created using a PopupTemplate. So far so good. We would like to display the values for {providers_phone_number} and for {providers_email}.

There starts the trouble.

First of all, these fields don't always contain values. If the field is empty, we don't want to display the corresponding line in the popup. Currently, in some browsers it adds an empty line and in some browser it adds "NaN". We suppose, a possible workaround would be to access the values before displaying them in the popup and build the PopupTemplate accordingly, e.g. if the value exists, it will be added, if the value doesn't exist, it won't be added to the content. --> How can we  access the value?

Secondly, the email-address is not always correctly written and sometimes contains uppercase letters. We would like to transform all mail addresses to all lowercase letters before displaying them. Thus we're wondering the same as above --> How can we access the value before displaying it? (or: why does {providers_email}.toLowerCase() not work?)

I created a codepen: https://codepen.io/nwp_nadja_bernhard/pen/NWMogwm

 

0 Kudos
0 Replies