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);
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.