I'm working in Javascript on a Maps API project for work. I'm having trouble with the callback function which I pass to GetLocations
in which it has to call another chunk of code (all the callback does is store the lat and lng into an object). But after the function does its work, the next function doesn't get called.
How does this callback work? Why can't I call any functions from it? What can I do in it?
update
Well the test function (which just made an alert box) I was using started magically working again, and I checked the error log (which I forgot existed before) to see what was going wrong.
The Javascript is using the prototype framework to do some kind of OO and the function that has to get called is "this.Create". The error said there's no such function, but it lets me call it from another place in the code:
for (var i=0;i<mapObjects.length;i++) {
mapObjects[i] = new mapObject(mapObjects[i]);
mapObjects[i].Create(); //this works
}
mapObject.prototype.SetLocation=function (response) {
this.geoStatusCode = response.Status.code;
alert("entered SetLocation with status code "+this.geoStatusCode);
if (this.geoStatusCode == 200) {
this.lat = response.Placemark[0].Point.coordinates[1];
this.lng = response.Placemark[0].Point.coordinates[0];
alert("calling create()");
this.Create(); //"no such function"
} else {
this.geofailed++;
}
}
I'm not really familiar with Javascript, and don't really understand prototype or how it works, so I have no idea how to solve this. Anyone know?