Support

Account

Home Forums General Issues Update google map field Reply To: Update google map field

  • 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);