Support

Account

Home Forums Backend Issues (wp-admin) Google Map TypeError

Solved

Google Map TypeError

  • I’m trying to use the Google Map field, but when I go to the post type to use the field WordPress has an error in the console: TypeError: ‘undefined’ is not an object (evaluating ‘new google.maps.places.Autocomplete’) and I’m not able to search for an address.

    I’ve looked around online and people are saying you need to include http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places to fix this issue but I’m not sure how to do that.

    Does anyone have any suggestions or input?
    Thanks so much!

    -David

  • Hi @controlyours

    ACF includes this script already, although it does it through jQuery $.getScript instead of a script tag.

    In your browser, you can inspect all scripts loaded into the page via the firebug/inspector panel.

    If you open that up and clic ont he scripts or network tabs, you can see all the files being loaded.

    Firstly check for any other JS errors in the console log, but then check the script is being loaded. Perhaps there is a firewall that is preventing the google API from loading?

    Thanks
    E

  • The only error in the console is the one I mentioned and the source of the error is input.min.js on line 1176

    Is there a particular js file I should check to be sure it loaded in the list? I’m not sure why this would be happening. :/

    Any suggestions?

    -David

  • Hi @controlyours

    I would look in the ‘network’ tab for any script which is not working. Are there any scripts that appear with an error? Perhaps one of them is the google API?

    It is possible that your website is already including the google API, but not including the places module.

    Can you check your source code for any google maps script?

    Thanks
    E

  • My theme was already pulling in the Google Maps script, so I removed that and it’s working now! Sorry to be such a pain!

    -David

  • Hi @elliot,

    Thanks for your excellent work.

    I have also found the same issue that @controlyours had, but the script was being loaded just fine. The problem I found is that it wasn’t getting the places library.

    I changed the js call in wp-content/plugins/acf-location-field/location-v4.php in Ln 94 from

    echo '<script src="https://maps.googleapis.com/maps/api/js?sensor=false" type="text/javascript"></script>';

    to

    echo '<script src="//maps.googleapis.com/maps/api/js?sensor=false&libraries=places" type="text/javascript"></script>';

    How do you feel about this approach? I am not happy to change the plugin files, since an update could remove those.

    Many thanks,
    Manu

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

The topic ‘Google Map TypeError’ is closed to new replies.