PDA

View Full Version : Setting location on Geolocation



KPChow
28 Oct 2011, 3:25 AM
Hi guys,

I'm having trouble setting the coordinates for my geolocation.



var pnt = new google.maps.LatLng(53.800651,-4.064941);
var geoPanel = new Ext.Map({
title: 'Map',
iconCls: 'map',
mapOptions:{
center: pnt,
zoom: 12,
},
});


When I try and load this code, I get the following error:

Uncaught ReferenceError: google is not defined

So when I comment out the 'pnt' variable, the map loads fine and shows default position of 'PaloAlto'. If someone can shed some light and explain why I'm getting this probem, that would be great! :-/

K

mitchellsimoens
28 Oct 2011, 6:10 AM
Did you include the google JS script tag in your index.html?

KPChow
28 Oct 2011, 6:13 AM
Hi mitchellsimoens,

You this right?

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>

If so, then yes I have. Having said that, does that script need to be placed above the senchatouch.js file, or it shouldn't matter?

mitchellsimoens
28 Oct 2011, 6:17 AM
Having said that, does that script need to be placed above the senchatouch.js file, or it shouldn't matter?

Shouldn't matter as the onReady shouldn't fire until after those script tags are loaded. One thing I see is you don't have spaces in your script tag so you may want to make sure you have a space between 'script' and 'type'. If you look at the Net tab in your debugger, is the script tag being loaded ok?

KPChow
28 Oct 2011, 6:21 AM
Shouldn't matter as the onReady shouldn't fire until after those script tags are loaded. One thing I see is you don't have spaces in your script tag so you may want to make sure you have a space between 'script' and 'type'. If you look at the Net tab in your debugger, is the script tag being loaded ok?

Sorry mitchellsimoens, that was a typo error on my side. I've re-checked the script tag with the debugger and yes they are loading ok.

KPChow
31 Oct 2011, 1:30 AM
Found the issue... It turns out that the google map script has to be loaded first before the other JS files...