PDA

View Full Version : GMapPanel: "a is undefined" when trying to create GPolyline's



abaird
31 Aug 2010, 5:58 PM
Hi all,

I'm getting stuck on a piece of code, mostly because Google's API is quite unhelpful when getting errors due to the packing.

I'm trying to render a circle around a marker via a click listener on my DataView. It renders the markers just fine, but when I attempt to create a GPolyline (the error occurs when I attempt to create GPolyline not when I try to add the overlay). The error firebug reports is:


a is undefined
[Break on this error] function Eh(a){x(gd).EU();eval(a)}

Offending code is below:

listeners: {
selectionchange: {
fn: function(dv,node){
Ext.getCmp('mapPanel').getMap().clearOverlays();
var day = $(node).children('.weekly-day').text();
store.each(function(rec) {
if (rec.data.weekday==day) {
for (i=0;i<rec.data.games.length;i++) {
var game = rec.data.games[i];
var point = new GLatLng(game.host_lat,game.host_lng);
var icon = new GIcon(G_DEFAULT_ICON);
icon.image = '/media/images/admin/map_marker_' + game.level_class + '.png';
icon.iconSize = new GSize(26,35);
var options = {
icon: icon
}
Ext.getCmp('mapPanel').getMap().addOverlay(new GMarker(point,options));
var points = [];
var radius = 10;
var d2r = Math.PI/180;
var r2d = 180/Math.PI;
var Clat = (radius / 3963)*r2d;
var Clng = Clat/Math.cos(game.host_lat*d2r);
for (var j=0;j<41;j++) {
var theta = Math.PI * (j / (j/2));
Cx = game.host_lng + (Clng * Math.cos(theta));
Cy = game.host_lat + (Clat * Math.sin(theta));
points.push(new GLatLng(Cy,Cx));
}
points.push(points[0]);
Ext.getCmp('mapPanel').getMap().addOverlay(new GPolyline(points,'#ff0000',5,.8));
}
}
});
}
}
}

At this point, I'm completely lost. Any thoughts?

Animal
31 Aug 2010, 9:29 PM
Break there, go back through the call stack to see where a comes from.

abaird
1 Sep 2010, 10:25 AM
The problem is the callstack itself is pretty hard to read through, again due to all the packing. The "Stack" tab doesn't seem to give any info on the variables that are being passed, it's just a list of functions that do nothing when I click on them in Firebug.
The scope chain is also pretty useless - with both ExtJS loaded and google map's JS files, there's a massive amount of global variables.

If you have a good way to look through this though I'm all ears :)

Animal
1 Sep 2010, 11:51 AM
Ext does not use global vars.

You are using ext-all-debug.js in development. Aren't you?