Created
July 23, 2010 15:06
-
-
Save aikar/487549 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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