简体   繁体   中英

google maps callback error on function name

I'm getting this error in webdev console when I run my html page code

nc {message: "initialize is not a function", name: "InvalidValueError", stack: 
"Error↵    at new nc (https://maps.googleapis.com/m…
##################&callback=initialize:137:68"}

I've based my code off the googlemaps api sample and only altered styling having not changed the function.

The function was called initMap though I have recently changed this to see if it made any difference.

My javascript url is https://comfortestateplanning.co.uk/js/home.js initialize function and my testing site url is https://comfortestateplanning.co.uk/

I have worked out where the error was and how to answer my own question :)

I've determined that the javascript file with the Google Maps function in it should not be async . This would cause the function to load concurrently with the Google Maps API call and not after it.

So in my case

<script async type="text/javascript" src="js/home.js"></script>

became (without async )

<script type="text/javascript" src="js/home.js"></script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM