Select to view content in your preferred language

Lat/Lon in Pop-up, "Cannot call member method on null"

2202
6
02-03-2020 07:14 AM
AprilChipman
Frequent Contributor

I've been using scripts to return the Lat and Lon of points in an ArcGIS Online webmap to create a Custom URL hyperlink that automatically opens a Survey123 survey on the exact point of an existing feature. It's been working great for over a year on various different webmaps.

I'm now upgrading all my webmaps to ArcGIS Enterprise. The script I've been using to get the Lat or Lon is now failing in the pop-up. I get an "Execution Error:Runtime Error: Cannot call member method on null. x"

Can anyone help me get this working again? This has become an integral part of our workflow!

0 Kudos
6 Replies
StephenPalka
Occasional Contributor

I'm running into a similar issue configuring a pop up in a web map in my organization's AGOL account.

The issue I'm running into is actually in a web app that uses the web map. The error doesn't pop up until I try to view or export data from the attribute table widget.

The issue seems to relate to accessing attributes of the geometry object. 

The following code causes the error:

// Convert Lines/Polygons to Points
var PointGeometry = Centroid(Geometry($feature));
var pointX = PointGeometry.x;
var pointY = PointGeometry.y;

return (text(pointX) + ":" + text(pointY);

While this does not:

// Convert Lines/Polygons to Points
var PointGeometry = Centroid(Geometry($feature));

return (text(PointGeometry));

Have you had any luck resolving this issue?

0 Kudos
JeffreySutherland
Esri Contributor

Hi April,

A couple of quick questions for you:

  • What version of ArcGIS Enterprise are you running?
  • Are you republishing the data in ArcGIS Enterprise before adding to your web maps? Is so, are they being published as hosted feature services?
  • Is the data identical between your ArcGIS Online web maps and your ArcGIS Enterprise web maps?

Thanks,

Jeff

0 Kudos
AprilChipman
Frequent Contributor

I am on 10.6.1 ArcGIS Enterprise.

I believe so. We are publishing services from ArcMap and using the REST url to add them to the online map.

Yes, the field names are identical. I may have changed an alias or removed/hidden some fields, but the base data is the same.

April

0 Kudos
AprilChipman
Frequent Contributor

I may have found a workaround...

If I extract an individual layer from my service and add it directly to the webmap, I can use these scripts to pass through the Lat and Lon of the point to the survey.

If I add the service, with its 25 different layers to the webmap, the scripts do not work and throw the error above.

Unfortunately, adding each individual layer is time consuming and cumbersome. I hope there is another solution in the works.

0 Kudos
AprilChipman
Frequent Contributor

Update:  It's still not working.

I can get the scripts to be accepted as an attribute expression when a single layer has been added to the webmap. But the new points are not being added on top of the existing point. They are all showing up off the west coast of Africa, just like when Location Services is turned off for the ipad.

I'd really like to get this working. Can anyone help me?

0 Kudos
luis4018
New Contributor

Did you ever figure this our? Just a couple things to check, is the "shape" field turned on when you publish your map? Check projection of layers in map. Just a thought.

0 Kudos