A few things worked that I worked out this week:

  1. The require statement that precedes the Javascript in Esri’s examples is actually a part of Node.js, which explains the need for outFields within module-defined objects

  2. You can move all the stuff out of the index.html file and into its own script file (e.g., geofence.js) and call the script by adding the following line at the end of your head tag. I’ve found this to be easier to work with, especially in CodePen.io.

    <script src="./geofence.js"></script>
  3. I had trouble using Locate.graphic.geometry and trying to run Arcade’s Intersects tool on completely failed. Additionally, I want to be able to save multiple locations, so I am trying to record each time I click the Locate button.

  4. The Locate widget has an event called locate that triggers with a Position object. I can inspect the page using through my browser’s Console (see here for instructions) and I can see the position object that I get from the triggered event (see image below).

  5. Taking a closer look at what the console is printing, the highest level braces (curly brackets) represent the object, which I arbitrarily called ‘position’ in my code; however, the object has a property that is also called ‘position’ because that’s the position object. So, here I was thinking that ‘position’ was referencing my object called ‘position’ but it is actually referencing the parameter ‘position’ that is inside my object! A slight adjustment to the code changing my function’s variable name from position to evt (it’s an event object) and adding the variable name before the word position, like so:

    var data = {
      LATITUDE: evt.position.coords.latitude,
      LONGITUDE: evt.position.coords.longitude,
      NAME: "Test Point"
    };

    I now get my points created and they are successfully added to a new feature class with the assigned symbology of blue circles with a black outline (see image below).

Next steps

That should be a good start to get a geofencing storytelling application off the ground.

Challenges

It seems Esri is using Google APIs for returning geolocations and there may be an issue with usage limits (see here).

References


UPDATE 4/27

This is where I got with testing locations (html).

Lessons Learned:

Challenges:

This is what it looks like:

Figure. Manually scrubbed the JSON geometries from the ten largest polygons (by area) using ArcGIS Pro’s Feature to JSON with some format cleaning (done by hand; ugh again). Created a Polygon geometry within the Arcade expression for the unique value renderer. Used the Editor widget to update the location points and color them based on whether they are within (uses the Within function) the JSON-described polygon geometry. Red indicates false (not within) and blue indicates true (within).