Arun P Johny answered this question in the comments.
GeoManager = function () {
this.pos = {
lat: 0,
lng: 0
};
console.log("Geo ok...");
};
GeoManager.prototype.init = function (callback) {
var self = this;
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
self.updateLocation(position);
callback(position);
});
} else {
console.log("Geolocation is not activated!");
}
};
GeoManager.prototype.updateLocation = function (position) {
this.pos.lat = position.coords.latitude;
this.pos.lng = position.coords.longitude;
console.log(this.pos);
};
GeoManager.prototype.getLat = function () {
return this.pos.lat;
}
GeoManager.prototype.getLng = function () {
return this.pos.lng;
};
//returns an object
GeoManager.prototype.getPos = function () {
return this.pos;
};
var GM = new GeoManager();
GM.init(function () {
console.log('pos', GM.getPos())
});