Skip to content

Instantly share code, notes, and snippets.

@aikar
Created July 23, 2010 15:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aikar/487549 to your computer and use it in GitHub Desktop.
Save aikar/487549 to your computer and use it in GitHub Desktop.
/*
* 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