Support

Account

Home Forums Backend Issues (wp-admin) Hook to Google Map Init/Loader

Solving

Hook to Google Map Init/Loader

  • Hi Everyone,

    Finally, Joining the ACF community with this first post. I have to admit this has been the most amazing WP plugin I ever come across!

    Alright, I would love to know though if anyone had the chance to hook with the google maps load/init functions? I traced where the functions are located and its apparently not a good thing to directly modify the source file to prevent issues from future updates. The idea is I’ll be creating another field type that makes use of the map apis. Loading the api again makes the fields broken (both the google map field and the one I’m trying to create.)

    Would love to hear whatever you can say regarding this matter.

    To Elliot, just to let you know you are immensely appreciated for bringing this unto the WordPress world.

  • 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

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Hook to Google Map Init/Loader’ is closed to new replies.