javascript - InvalidValueError: initAutocomplete is not a function Google Places and Autocomplete API -


hope can i've hit wall, i'm quite new using google's places apis.

i'm not going post code yet code works fine when 2 pieces describe run in isolation.

i using google's places in addition autocomplete api working javascript examples provided google.

initially had following script @ bottom of document:

<script src="https://maps.googleapis.com/maps/api/js?&libraries=places&callback=initautocomplete" async defer></script> 

and script @ top of document:

 <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script> 

this gave me the, "you have included google maps api multiple times on page. may cause unexpected errors." after looking merged both this:

<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places&callback=initautocomplete&sensor=false"></script> 

however, have done this, receive following errors:

invalidvalueerror: initautocomplete not function typeerror: searchbox undefined 

i don't receive these errors when theses scripts not merged, realised afterwards functions requiring places api stopped working. if remove autocomplete api reference, places functions work.

any ideas on how can make both of these work together, merging these shown , solving 'not function' issue?

any suggestions appreciate, please let me know if need see code.

thanks in advance, steph

you should use include script once, like:

//maps.googleapis.com/maps/api/js?key=__api-key__&libraries=places 

note omit 'callback' param when including script. load initautocomplete on window load like:

google.maps.event.adddomlistener(window, 'load', initautocomplete); 

maybe need include gmaps script in head or 'google not defined' error, if placed js inline.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -