Arcade Expression is not working in Web app builder

978
6
Jump to solution
05-07-2019 02:06 PM
Pier-PhilippeLabrie
New Contributor II

Hi everyone, I've wrote an expression with arcade in agol. The expression is a link to GoogleMap. So when you click on a feature it redirects you to a GoogleMap link with lat & lng issued from the geometry.

Here's the issue: when I deploy the application with WAB the expression no longer works and just displays the name:

No link From WAB:

Capture from the application

OK Link in arcGIS online:

Capture from the arcgis map

0 Kudos
1 Solution

Accepted Solutions
XanderBakker
Esri Esteemed Contributor

Hi Pier-Philippe Labrie ,

I haven't tried and I don't use the dev edition of WAB, but since support for Arcade has only recently introduced, it is very likely that using an older version is the reason for it not working. Please upgrade and try again. 

View solution in original post

6 Replies
XanderBakker
Esri Esteemed Contributor

That is strange... It works just fine for me in both the Web Map and the Web AppBuilder: 

Can you share the definition of the Arcade expression and configuration of the pop-up in the web map?

Pier-PhilippeLabrie
New Contributor II

Hi Xander, Here's the code I'm using to construct the link...you actually posted that

I made a video capture to get all the context.

So I' m using WebAPP Builder for Developper to construct the app locally and then I deploy it on my server. So, when I'm working locally on my computer, the link created is actually pointing on localhost instead of pointing to googleMap, Then when I upload the app on the server it points to the root of the app (where the index.html file is located). You will see that in the video.

I've done link creation before but I would do it directly from the shapefile (with a field calculation) and then upload the shapefile in AGOL. and this works perfectly. Meanwhile I will try to create the app direct in the webAPP buildder within AGOL.

Thanks for your help

Cheers

//-----------------

function MetersToLatLon(mx, my) {
// Converts XY point from Spherical Mercator EPSG:900913 to lat/lon in WGS84 Datum
// Fuente: http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/
var originShift = 2.0 * PI * 6378137.0 / 2.0;

var lon = (mx / originShift) * 180.0;
var lat = (my / originShift) * 180.0;

lat = 180.0 / PI * (2.0 * Atan( Exp( lat * PI / 180.0)) - PI / 2.0);
return [lat, lon];
}


var poly = Geometry($feature);

var result = "";
if (!IsEmpty(poly)) {
var pnt_centr = Centroid(poly);

var latlon = MetersToLatLon(pnt_centr.x, pnt_centr.y);

result = "https://www.google.ca/maps/dir//" + Round(latlon[0], 6) + ", " + Round(latlon[1], 6);
} else {
result = "";
}

return result;

//-----------------

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi Pier-Philippe Labrie ,

My first question would be: what version of the developer version are you using? 

If you use the web map and create an application using the AGOL WAB, the link will work, right?

0 Kudos
Pier-PhilippeLabrie
New Contributor II

Hi Xander, So I'm testing using the webAPP that is within AGOL....and it looks like it's working.

Else, when this problem happened I was using arcgis-web-appbuilder-2.4 ...So I figure I should update this application since we are on V2.12 now.

Can you make it work with a new version of WAB for developper?

Thanks!

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi Pier-Philippe Labrie ,

I haven't tried and I don't use the dev edition of WAB, but since support for Arcade has only recently introduced, it is very likely that using an older version is the reason for it not working. Please upgrade and try again. 

Pier-PhilippeLabrie
New Contributor II

Thanks for the advise Xander, it works perfectly with the new 2.12 WebAPPbuilder for developper.

It was definetly a Version problem.

Cheers!