Home Forums General Issues Cannot update field with Nominatim


Cannot update field with Nominatim

  • Hi,
    I created 2 fields (latitude and longitude) to update a third field with “location name”, using Nominatim, with php code.


    $lat_start = 47.5;
    $lon_start = 4.5;

    function getAddress($RG_Lat,$RG_Lon)
    $json = “;.$RG_Lat.”&lon=”.$RG_Lon.”&zoom=10&addressdetails=1″;

    $ch = curl_init($json);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_USERAGENT, “Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0”);
    $jsonfile = curl_exec($ch);

    $RG_array = json_decode($jsonfile,true);

    return $RG_array[‘display_name’];

    $addr = getAddress($lat_start,$lon_start);
    echo “Address: “.$addr;


    Problem :
    If I execute code with numbers ($lat = 47.5 and $lon = 4.5), it works fine.
    But it doesn’t seem to work with variables. 🙁
    How can I replace numbers with acf fields content (called “lat_start” and “lon_start”) ?

  • ACF is probably returning a sting value, convert the value returned by acf using floatval()

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.