Select to view content in your preferred language

Nearest Address works online but in Field Maps

192
5
Jump to solution
3 weeks ago
DerekBernard
Frequent Contributor

Just a simple script to have a new point search for the nearest property and update a text field with the new address.  Seem to work fine in the Online version, but in Field Maps it gives me a "Failed to Calculate" message.

var searchDist = 100;

    var addresses = Intersects(FeatureSetByName($map, "Parcels"), Buffer( $feature, searchDist, "feet"));
 
    var nearestaddress = "";
    var min_dist = 150;
    for (var f in addresses){
        var addressDist = Round(Distance(f, $feature, "feet"),2);
        if (addressDist < min_dist) {
            nearestaddress = f.PROP_ADD1;
            min_dist = addressDist;
        }
    }

    return nearestaddress;
0 Kudos
1 Solution

Accepted Solutions
CodyPatterson
MVP Regular Contributor

Hey @DerekBernard 

This works when you add the point as the geometry is then delivered to the function after the point is added. The Field Maps calculation isn't made aware of any geometry prior to adding the actual point. You may have to inform the users that they need to add a point before the field calculation is completed.

Cody

View solution in original post

0 Kudos
5 Replies
DerekBernard
Frequent Contributor

Ok, I click the + symbol and the fields show up for editing and that's when I see the error message.  However, I just noticed once I click Add Point or Update Point then the scripts runs and updates the field.  Is there any way to have this run before the Add Point is clicked because it is confusing for users.

0 Kudos
CodyPatterson
MVP Regular Contributor

Hey @DerekBernard 

This works when you add the point as the geometry is then delivered to the function after the point is added. The Field Maps calculation isn't made aware of any geometry prior to adding the actual point. You may have to inform the users that they need to add a point before the field calculation is completed.

Cody

0 Kudos
DerekBernard
Frequent Contributor

That's not exactly a solution.  Any way to make this work?

0 Kudos
RhettZufelt
MVP Notable Contributor

The only way I see to add a point in Field Maps app without the add/update point button is to use the "Collect Here" option.

R_

CodyPatterson
MVP Regular Contributor

Hey @DerekBernard 

Please update your post to state that this will need to be without manual user input.

This is currently not possible given your restrictions, in order for Field Maps to obtain accurate locational geometry, you will need to have a point placed. Field Maps does not get geometry based off of the users location, the satellite information will approximate the users position with 30-50ft, but that is all. As Rhett mentioned, your users can use "Collect Here" but if they are not willing to automatically place down a point, then it is not possible. If you would like to add an idea to the Field Maps team, add it here:https://community.esri.com/t5/arcgis-field-maps-ideas/idb-p/arcgis-field-maps-ideas

Cody

0 Kudos