如何从前端表单在acf谷歌地图字段上插入位置?

时间:2019-05-07 06:34:44

标签: wordpress advanced-custom-fields

我有一个具有地址字段的自定义表单,我想将地址值放入acf谷歌地图字段

我用过update_field('field_5c87a29f0ad9a',$ address,$ post_id); 但这不起作用

1 个答案:

答案 0 :(得分:0)

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