TypeError:window.initMap不是一个函数 [英] TypeError: window.initMap is not a function

查看:427
本文介绍了TypeError:window.initMap不是一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习本教程,基本上复制了所有的代码。

https://developers.google.com/maps/documentation/javascript/tutorial



但出现错误,说明initMap函数不是一个函数。
我在我的项目中使用了angularjs,是否会导致问题?



我将相同的代码复制到plunker中,它工作得很好...
有什么可能的问题?

解决方案

事实证明它与 ng-Route 加载脚本的顺序
写了一个指令,并将API脚本放在所有工作的顶部。


I am following this tutorial, basically copy all the code

https://developers.google.com/maps/documentation/javascript/tutorial

but got an error saying that the initMap function is not a function. I am using angularjs in my project, could that be causing problems?

I copied the same code into plunker and it works just fine... What are the possible issues?

解决方案

turns out it has to do with ng-Route and the order of loading script wrote a directive and put the API script on top of everything works.

这篇关于TypeError:window.initMap不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆