Select to view content in your preferred language

Field Maps nearest address doesn't work, but does online.

209
2
Jump to solution
03-05-2025 09:20 AM
DerekBernard
Frequent Contributor

I created a form to pull the nearest address using a calculated field and created a mechanism to add a custom address if wanted.  It works fine in the Web Map, but in field maps, the address never shows up.

DerekBernard_0-1741194975078.png

Code for Editable Flag:

DomainName($feature, "IsAddressEdit") == "Yes"
 
Code for Calculated Expression:

var searchDist = 100;
    var addresses = Intersects(FeatureSetByName($map, "City Parcels"), Buffer( $feature, searchDist, "feet"));
    var cnt = Count(addresses)
    Console("Total Number of addresses within buffer: " + cnt);
    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;
        }
        Console(f.PROP_ADD1 + ": " + " " + addressDist);
    }

    return nearestaddress;
 
Works fine in Web Map:
DerekBernard_1-1741195108561.png

 

Doesn't work in Field Maps.

 

0 Kudos
1 Solution

Accepted Solutions
DerekBernard
Frequent Contributor

I did not have my "Custom Address" switch visible in the Pop-up screen (because I did not really want it there.)  When I added it into the Pop-up, it started working.  It was always available in the edit screen, but making it available in pop-up is what worked.

View solution in original post

0 Kudos
2 Replies
KerriRasmussen
Esri Contributor

Hi @DerekBernard , try removing the console statements are using something similar to this:

//Call the parcel layer as a feature set
var town = FeatureSetByName($map, "Parcels");

//Create a variable for the nearest parcel to the sign using a 50ft buffer
var nearestTown = First(Intersects(town, BufferGeodetic($feature, 50, "feet")));

//Return the name of the nearest town
return nearestTown.SITUS_COMMUNITY;
DerekBernard
Frequent Contributor

I did not have my "Custom Address" switch visible in the Pop-up screen (because I did not really want it there.)  When I added it into the Pop-up, it started working.  It was always available in the edit screen, but making it available in pop-up is what worked.

0 Kudos