You have a problem with scope - every time you hit a callback there is a possibility that you loose the definition of this
. Try using the bind()
on the callback to define what this
is in the function context. I've noted the calls below. You can also simplify the class definition as well as below
Garmin.GoogleEarthMapController = Class.create({
initialize: function (mapString) {
// make sure you bind this call
google.setOnLoadCallback(this.GEinit.bind(this));
},
GEinit: function() {
alert("call create");
//This is a Google.js function and works when executed outside of prototype
//make sure you bind this call
google.earth.createInstance(this.mapElementName, this.GEinitCallback.bind(this), this.GEfailureCallback.bind(this));
alert("finished create instance");
},
GEinitCallback: function (instance) {
alert("init called");
},
GEfailureCallback:function (errorCode) {
}
});