Select to view content in your preferred language

Point-in-polygon calculation not working on point layer with related table

126
1
Jump to solution
3 weeks ago
EricaNova
Frequent Contributor

I've set up a map in Map Viewer that I am planning to use in Field Maps. I've used forms to auto-fill certain fields based on other layers in my map. For example, capture a user's location and use it to fill the "Site" field.

For one of my layers, a polyline layer, this works great in both Map Viewer and Field Maps using the following code:

// Create a feature set using the ‘Sites’ layer in the map
var studysites = FeatureSetByName($map, 'Sites', ['Site'])

// Intersect the current location with the studysites and
// get the first region
// *** ...
var studysite = First(Intersects($feature, studysites))

// If the current location does intersect a feature,
// return the name of the region. Otherwise, return null
if (!IsEmpty(studysite)) {
  return studysite['Site']
} else {
  return null
}

Unfortunately, I have another layer - a point layer with a related table - where I can't get the exact same code to work. I'm trying to pull the site (polygon layer) for each new point added, and it's working in Map Viewer but not Field Maps. Every so often, the correct Site briefly 'flashes' tauntingly at me in Field Maps then disappears. What is happening!!!??? I've been pulling my hair out on another problem all day and just about ready to throw in the towel... 

0 Kudos
1 Solution

Accepted Solutions
EricaNova
Frequent Contributor

Well, hopefully this will help someone... I 'solved the problem' by saving my form to the layer, removing the layer from the map, and re-adding it. Once I did that and saved the map, the form was working. Too bad about the 2.5 hours I spent troubleshooting this yesterday..... Gah

View solution in original post

0 Kudos
1 Reply
EricaNova
Frequent Contributor

Well, hopefully this will help someone... I 'solved the problem' by saving my form to the layer, removing the layer from the map, and re-adding it. Once I did that and saved the map, the form was working. Too bad about the 2.5 hours I spent troubleshooting this yesterday..... Gah

0 Kudos