Javascript错误 - 找不到变量:google [英] Javascript Error - Can't find variable : google

查看:119
本文介绍了Javascript错误 - 找不到变量:google的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写的代码在浏览器上运行得很好。但是当我连接到iPhone上的wifi时,我在调试器中收到错误:
Javascript错误 - 找不到变量:google



调用任何google maps / directions / geoLocation对象。






代码如下:

  map = new Ext.Map({
mapOptions:{
center:center,
zoom:20,
// mapTypeId:google.maps.MapTypeId .ROADMAP,
navigationControl:true,
navigationControlOptions:{
style:google.maps.NavigationControlStyle.DEFAULT
}
},

听众:{
maprender:function(comp,map){
pos = new google.maps.LatLng(lats,longs,true);
var marker = new google.maps.Marker {
position:pos,
// title:'Sencha HQ',
map:map
});

map.setMapTypeId(google。 maps.MapTypeId.HYBRID);
setTimeout(function(){map.panTo(pos);},1000);
}
},

geo:新的Ext.util.GeoLocation({
autoUpdate:true ,
maximumAge:0,
timeout:2000,
listeners:{
locationupdate:function(geo){
pos = new google.maps.LatLng(lats,真实的)
center = new google.maps.LatLng(geo.latitude,geo.longitude);
if(map.rendered)
map.update(center)
else
map.on('activate',map.onUpdate,map,{single:true,data: POS});
},
locationerror:function(geo,bTimeout,bPermissionDenied,bLocationUnavailable,message){
if(bLocationUnavailable){
alert('您当前的位置在此设备上不可用] );
}
else if(bPermissionDenied){
alert('本地设备上的位置功能已被禁用);
}
}
}
})
});

错误发生在代码遇到单词google时。另外对于LatLng对象,我得到javascript错误:.... LatLng的结果不是构造函数



注意:变量lat和longs有在这段代码之前定义了给定的值

解决方案

所以我以前发表过这个评论,实际的解决方案,我会再发布一次:D



确定,我得到所有这些错误的原因是我是一个代理。奇怪的是,当我使用LAN电缆连接时,代理可以让我访问google库和服务器,但是当我使用WiFi时希望some1其他谁坚持这种错误会发现这有点有帮助:)


The code I wrote runs absolutely fine on the browser. But when I connect to wifi on the iPhone I get an error in the debugger : Javascript Error - Can't find variable : google

This occurs whenever I call any google maps/directions/geoLocation object.


The code is as follows :

map = new Ext.Map({
    mapOptions : {
        center : center,
        zoom : 20,
       // mapTypeId : google.maps.MapTypeId.ROADMAP,
        navigationControl: true,
        navigationControlOptions: {
                style: google.maps.NavigationControlStyle.DEFAULT
            }
    },

    listeners : {
        maprender : function(comp, map){
            pos = new google.maps.LatLng(lats, longs, true);
            var marker = new google.maps.Marker({
                 position: pos,
                 //title : 'Sencha HQ',
                 map: map
            });

            map.setMapTypeId(google.maps.MapTypeId.HYBRID);
            setTimeout( function(){map.panTo (pos);} , 1000);
        }
    },

     geo:new Ext.util.GeoLocation({
         autoUpdate:true,
         maximumAge: 0,
         timeout:2000,
         listeners:{
             locationupdate: function(geo) {
                 pos = new google.maps.LatLng(lats, longs, true);
                 center = new google.maps.LatLng(geo.latitude, geo.longitude);
                 if (map.rendered)
                     map.update(center)
                 else
                     map.on('activate', map.onUpdate, map, {single: true, data: pos});
             },
             locationerror: function(geo, bTimeout, bPermissionDenied, bLocationUnavailable, message) {
                 if(bLocationUnavailable){
                     alert('Your Current Location is Unavailable on this device');
                 }
                 else if (bPermissionDenied){
                     alert('Location capabilities have been disabled on this device.');
                 }      
             }
         }
     })
});

The error occurs whenever the code encounters the word google. Also for the LatLng object I get the javascript error : "....result of LatLng not a constructor"

Note : the variables "lats" and "longs" have been defined n given values before this segment of code

解决方案

So I had posted this earlier as a comment, but since this is the actual solution to the problem, I'm gonna post it once more :D

Ok turns out that the reason I was getting all those errors is cos I was behind a proxy. Weirdly enough the proxy lets me access the google libraries and server when I'm connected using the LAN cable, but not when Im using WiFi. Hope some1 else who's stuck wid this kind of error will find this somewhat helpful :)

这篇关于Javascript错误 - 找不到变量:google的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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