Support

Account

Home Forums General Issues ACF and Geo Mashup integration

Unread

ACF and Geo Mashup integration

  • How to combine multiple locations onto one Google map using ACF and Geo Mashups

    This is how you integrate ACF’s Google Maps field with Geo Mashup.

    http://wpquestions.com/question/showLoggedIn/id/10778

    add this to your functions.php

    add_action('save_post', 'wpq_acf_gmap');
    
    function wpq_acf_gmap($post_id) {
    
       if(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return $post_id;
    
       if( !isset($_POST['acf_nonce'], $_POST['fields']) || !wp_verify_nonce($_POST['acf_nonce'], 'input') ) return $post_id;
    
       
    
       if(get_post_status( $post_id ) <> 'publish' )  return $post_id;
    
          
    
       $location   = (array) ( maybe_unserialize(get_post_meta($post_id, 'location', true)) ); //change location as your acf field name
    
       if( count($location) >= 3 ) {
    
          $geo_address = $location['address'];
    
          $geo_latitude = $location['lat'];
    
          $geo_longitude = $location['lng'];
    
          $geo_location = ''.$geo_latitude.','.$geo_longitude.'';
    
          update_post_meta( $post_id, 'geo_address', $geo_address );
    
          update_post_meta( $post_id, 'geo_latitude', $geo_latitude );
    
          update_post_meta( $post_id, 'geo_longitude', $geo_longitude );
    
          update_post_meta( $post_id, 'geo_location', $geo_location );
    
       }
    
    }

    .

    Configure Geo Mashups as per the following…

    • Collect Location For: untick all options (all locations will be collected from ACF)
    • Copy Geodata Meta Fields: thick this option, since the Geodata was created by ACF
    • Enable Reverse Geocoding: thick this option to look up missing address.
Viewing 1 post (of 1 total)

The topic ‘ACF and Geo Mashup integration’ is closed to new replies.