Home › Forums › Backend Issues (wp-admin) › Hook to Google Map Init/Loader › Reply To: Hook to Google Map Init/Loader
Hi drebbits,
have you found a Solution to this Problem yet?
I’m also trying to hook into the Google Maps initialisation process to Load some Geodata (LAT/LNG) from an external Database an show this position on the Google Map, when its loaded.
**** EDIT ****
Found a Solution for my problem, which was quit easy:
add_filter('acf/load_value/name=geo_map', 'hook_gmap_value', 10, 3);
function hook_gmap_value( $value, $post_id, $field ) {
// Check if Travel-DB Entry for this Post exists
global $wpdb;
global $geo_table;
$db_check = $wpdb->get_var( "SELECT COUNT(*) FROM $geo_table WHERE item_id = $post_id" );
// DB Entry exists, get the GEO-Data and load the GoogleMap with this Data
if ( intval($db_check) !== 0 ) {
$data = $wpdb->get_row( "SELECT * FROM $geo_table WHERE item_id = $post_id" );
$value['address'] = $data->address;
$value['lat'] = $data->lat;
$value['lng'] = $data->lng;
}
return $value;
}
just hooking into the load_value works for me, but i’m afraid not for your problem ;-/
best regards,
serio
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.