Support » Plugin: Google Map for Contact Form 7 » Initialize Google map with javascript.

  • Resolved Jules Colle

    (@jules-colle)


    Is there a function I can use to initialize the map after duplicating it?
    I’m using a repeater, to duplicate any field in contact form 7. Is there a function I should call after duplication the field in order for it to appear properly?

    Something like: cf7GoogleMap.init()?

    • This topic was modified 1 month, 2 weeks ago by Jules Colle.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Aurovrata Venet

    (@aurovrata)

    I’m using a repeater, to duplicate any field in contact form 7.

    that’s a good question. had to tweak the front-end code a little.

    with v1.7.3 you can now do something like,

    
    $cloned_map = $map_container.clone();
    //initCF7googleMap() can be chained, but will return false if the element is not a .cf7-google-map-container element.
    if($cloned_map.is('.cf7-google-map-container')) $cloned_map.initCF7googleMap();
    

    the plugin is also fully compatible with the repetitive field constructs available with the Smart grid-layout plugin.

    Thanks Aurovrata! This works nicely.

    For anyone interested, the code I ended up with, when using CF Pro repeater is the following:

    jQuery('form').on('wpcf7cf_repeater_added', function(e) {
      // init map
      $newGMap = jQuery('.cf7-google-map-container', jQuery(e.target));
      if($newGMap.initCF7googleMap) {
        $newGMap.initCF7googleMap();
      }
    });
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.