Tuesday, June 4, 2024
 Popular · Latest · Hot · Upcoming
22
rated 0 times [  25] [ 3]  / answers: 1 / hits: 18633  / 13 Years ago, tue, september 27, 2011, 12:00:00

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


More From » iphone

 Answers
2

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 :)


[#89894] Monday, September 26, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
joseluispauld

Total Points: 13
Total Questions: 132
Total Answers: 98

Location: Venezuela
Member since Sat, Apr 24, 2021
3 Years ago
;