Restricting a radio button/switch based on proximity to a map point

159
0
a month ago
WILERMJOSEPERAZAPIMENTEL
New Contributor II

Hi everyone,

I hope this finds you well.

I'm working on a Fieldmaps project where I need to restrict the visibility of a radio button or switch based on the user's proximity to a selected point on the map. I want the form to only be active if the user is within 50 meters of the selected point.

I've searched the documentation and forums, but I haven't been able to find a solution for this specific scenario. I've tried using expressions and triggers, but I haven't been able to get it to work as expected.

Any suggestions or guidance would be greatly appreciated.

This is my calculated field in Arcade

Arcade code: 

// Verificar si el radio button es 'Visitado'
if ($feature.Llegada_al_Cliente == 'Visitado' && IsEmpty($feature.HoraIni) ) {
    // Asignar la hora actual a una variable
    var currentDateTime = Now();
    // Asignar la hora actual al campo 'HoraIni'
    return currentDateTime;
} else {
    // Si no es 'Visitado', mantener el valor actual del campo 'HoraIni'
    return $feature.HoraIni;
}

This is my idea, but it gives me an error.

// Verificar si el radio button es 'Visitado' y si la distancia al punto es menor a 50 metros
if ($feature.Llegada_al_Cliente == 'Visitado' && Distance($feature.location, $geometry) < 50) {
// Asignar la hora actual a una variable
var currentDateTime = Now();
// Asignar la hora actual al campo 'HoraIni'
return currentDateTime;
} else {
// Si no es 'Visitado' o la distancia es mayor a 50 metros, mantener el valor actual del campo 'HoraIni'
return $feature.HoraIni;
}
error: 
Invalid property identifier, expecting ObjectId
error: $feature.location

0 Kudos
0 Replies