简体   繁体   English

Google Maps api异步加载-尝试了所有解决方案-疯了

[英]Google maps api async loading - have tried all the solutions - going insane

I'm trying desperately to finish this project 我正在拼命地完成这个项目

http://kenziejoy.github.io/frontend-nanodegree-map/ http://kenziejoy.github.io/frontend-nanodegree-map/

(that is the gh-pages branch, the master is a little behind) (这是gh-pages分支,master落后了一点)

and while tinkering with other things my map disappeared...forever. 在修补其他事物的同时,我的地图消失了……直到永远。 I can't find what is wrong. 我找不到错在哪里。 I feel like I've tried everything: async, defer, async defer, callback to a function in the html that then calls a function in the js file (someone suggested it), initmap inside the viewmodel, outside the viewmodel, everything wrapped in a self running function. 我觉得我已经尝试了所有方法:异步,延迟,异步延迟,回调到html中的函数,然后在js文件中调用函数(有人建议这样做),视图模型内的initmap,视图模型外的所有内容,自运行功能。

Most of my errors are either, my callback isn't a function, google isn't defined or something in my js file isn't defined. 我的大多数错误是,我的回调函数不是函数,未定义google或未定义我的js文件中的某些内容。

I've poured through to make sure it isn't something silly like a misplaced comma - but I'm getting so frustrated I've probably made a stupid mistake somewhere. 我已经努力确保它不会像错位的逗号那样愚蠢-但是我感到非常沮丧,以至于我可能在某个地方犯了一个愚蠢的错误。 Just any help would be really appreciated. 任何帮助将不胜感激。 At least so I can get a map up there and make some progress on everything else. 至少这样我可以在那里找到地图,并在其他所有方面取得一些进展。

Looking at the code in your link In the app function in you main.js is not declared the googleMap var globally. 查看链接中的代码在您的app函数中,main.js未全局声明为googleMap var。

you must declare 你必须声明

var googleMap ;

in top of you main.js 在您之上main.js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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