javascript in ArcGIS Online

1930
2
Jump to solution
12-27-2017 08:47 AM
AmberCline
New Contributor

I'm attempting to use javascript in ArcGIS Online's popup in the mapviewer and am having some issues with getting a function to stick with it.

I have added a LiveFeed layer, NOAA_METAR_current_wind_speed_direction from the MapServer. However, the Wind Speed is displayed in km/h and I would like convert it to mph.

However, I've been unsuccessful in getting a function for converting the data to work. What ultimately happens is that when I 'ok' the script in the Custom Attribute Display, nothing will happen, and when I reopen to check the script - it has disappeared. 

I've attempted to enter a simple divide function, tried closing the function in <script> </script>, etc and it all disappears when I reopen the Custom Attribute Display. I'm almost thinking that AGOL doesn't allow you to apply conversions to the data.

If anyone has advice on how to convert km/h to mph successfully, it would be greatly appreciated. 

If further clarification is needed, please let me know. 

Thank you

1 Solution

Accepted Solutions
by Anonymous User
Not applicable

Amber Cline‌ - Yes! They recently added this capability for Javascript logic to popups.

Configure pop-ups—ArcGIS Online Help | ArcGIS  

Arcade in Popup  ArcGIS Arcade | ArcGIS for Developers  

Let us know if this works!  

I use this now to swap internal links to external URLs with the Replace function to change text in a string of a field, as another example. It's sweet.

View solution in original post

0 Kudos
2 Replies
by Anonymous User
Not applicable

Amber Cline‌ - Yes! They recently added this capability for Javascript logic to popups.

Configure pop-ups—ArcGIS Online Help | ArcGIS  

Arcade in Popup  ArcGIS Arcade | ArcGIS for Developers  

Let us know if this works!  

I use this now to swap internal links to external URLs with the Replace function to change text in a string of a field, as another example. It's sweet.

0 Kudos
KellyGerrow
Esri Frequent Contributor

Using Arcade will be your best method to covert the windspeed using attribute expressions. Here is the html that is supported through the html editor in pop ups:

Supported HTML—ArcGIS Online Help | ArcGIS 

-Kelly

0 Kudos