Support

Account

Home Forums General Issues Update google map field

Solving

Update google map field

  • I have to update the google map field with php, when I send the address and the coordinates, it doesn’t update, here is my code:

    $value = array(“address” => $fullAddress, “lat” => $latitude, “lng” => $longitude);

    update_field(‘coordinates’, $value, $post_id);

    can anyone help me?

    thanks in advance

  • did you manage to solve this?

  • Actually yes, but I had to check the database to see how a normal google map mark was being saved, because the google map mark is an array with the address, the latitude and the longitude, so I had to create the array and then send it to the custom field with update_post_meta

    $coordinates = getCoordinates($fullAddress);
            $coordinates = explode(",", $coordinates);
    
            $latitude = $coordinates[0];
            $longitude = $coordinates[1];
    
            $google_map_mark = array();
            array_push($google_map_mark, "address");
            array_push($google_map_mark, $fullAddress);
            array_push($google_map_mark, "lat");
            array_push($google_map_mark, $latitude);
            array_push($google_map_mark, "lng");
            array_push($google_map_mark, $longitude);
    
            $value = array("address" => $fullAddress, "lat" => $latitude, "lng" => $longitude);
    
    update_post_meta($post_id, 'coordinates', $value);
Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Update google map field’ is closed to new replies.