Skip to content

Instantly share code, notes, and snippets.

@aikar aikar/gist:487549
Created Jul 23, 2010

Embed
What would you like to do?
/*
* google.maps.LatLng Hijack
*/
// $require: game/init.js
(function()
{
var GLATLNG_LAT = null;//"Ud";
var GLATLNG_LNG = null;//"La";
var g = new google.maps.LatLng(42,23);
for(var i in g)
{
if(g.hasOwnProperty(i) && (!GLATLNG_LAT || !GLATLNG_LNG))
{
if(g[i] == 42)
{
GLATLNG_LAT = i;
}else if(g[i] == 23)
{
GLATLNG_LNG = i;
}
}
}
delete google.maps.LatLng.prototype.lat;
delete google.maps.LatLng.prototype.lng;
Object.defineProperty(google.maps.LatLng.prototype, 'lat', {
get:function()
{
var ll = this;
var func = function() {return parseFloat(ll[GLATLNG_LAT]);};
func.toString = func;
return func;
},
set: function(val) {this[GLATLNG_LAT] = parseFloat(val.toString());}
});
Object.defineProperty(google.maps.LatLng.prototype, 'lng', {
get:function()
{
var ll = this;
var func = function() {return parseFloat(ll[GLATLNG_LNG]);};
func.toString = func;
return func;
},
set: function(val) {this[GLATLNG_LNG] = parseFloat(val.toString());}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.