谷歌地图v3与MeteorJS加载同步问题 [英] Google Maps v3 with MeteorJS loading sync issue

查看:117
本文介绍了谷歌地图v3与MeteorJS加载同步问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序在MeteorJS框架上运行并使用谷歌地图(javascript api v3)。 Google地图加载方案与此文章中介绍的相似,与官方的教程。但有时在它的加载应用程序抛出一个重复的异常:


未捕获TypeError:无法读取属性'纬度'为空


下面这段代码会导致它(不幸的是,缩小):

 < ($,$,$,$,$,$,$,$,$,$) 
f [p](title,e);
b [p](draggableCursor,e,游标);
var g = e.Nb;
Q(click dblclick rightclick mouseover mouseout mousemove mousedown mouseup.split(),function(d){
S [z](b,d,function(e,q,s){
var v = a [Wp](e,!0);
e = new U(v.lat(),v.lng()); //这里v可能为空
})
})
}

我很确定这是加载同步问题:a)应用程序工作正常,仅在加载的第一秒内抛出错误。 b)这种情况在生产中经常发生,自然加载时间更长。

我可以链接到我的应用程序,如果它有帮助。

解决方案

那么加载错误的原因奠定了初始化函数。该功能创建了一个没有地图选项的地图,当与Meteor服务器端建立连接时,地图选项被添加到地图中。在地图创建和选项设置之间的这段时间差距出现了。课程是:在相同的代码片段中添加选项以创建地图。

My app is running on MeteorJS framework and using google maps (javascript api v3). Google maps loading scheme is similar to one explained in this post, and it's pretty analogous to the official tutorial. But sometimes on it's loading the app throwing a repeated exception:

Uncaught TypeError: Cannot read property 'lat' of null

the following piece of code cause it (unfortunately, minified):

function $H(a, b, c, d) {
    var e = c[B], f = new jB(d);
    f[p]("title", e);
    b[p]("draggableCursor", e, "cursor");
    var g = e.Nb;
    Q("click dblclick rightclick mouseover mouseout mousemove mousedown mouseup".split(" "), function(d) {
        S[z](b, d, function(e, q, s) {
            var v = a[Wp](e, !0);
            e = new U(v.lat(), v.lng()); //here, v is probably null 
        })
    })
}

I'm pretty sure that's loading synchronization issue: a) the app is working fine and the errors are thrown in only first seconds of loading. b) this happens much frequently in production, naturally the loading times there are longer.

P.S. I can link to my app if it'll help.

解决方案

Well the reason to the loading errors laid in initialize function. The function created a map without map options, and when connection with Meteor server side was established, map options were added to the map. In this gap of time between map creation and options setting the errors appeared. The lesson is: add options to created map in the same code piece.

这篇关于谷歌地图v3与MeteorJS加载同步问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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