Created
July 26, 2012 13:41
-
-
Save zevarito/3182088 to your computer and use it in GitHub Desktop.
Revisions
-
zevarito created this gist
Jul 26, 2012 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ define("Geolocation", { deviceSupport: function() { if(navigator.geolocation) return true; else if(google.gears) return true; else return false; }, start: function(success_callback, error_callback) { // Try W3C Geolocation (Preferred) if(navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { success_callback(position.coords.latitude, position.coords.longitude); }, function() { error_callback(); }, { enableHighAccuracy: true, maximumAge: 600000 }); // Try Google Gears Geolocation } else if (google.gears) { var geo = google.gears.factory.create('beta.geolocation'); geo.getCurrentPosition(function(position) { success_callback(position.latitude, position.longitude); }, function() { error_callback; }); } }, // Returns a "mocked" like object representing Google LatLng // Default position is set up to Portland/USA. default_position: function() { var latLng = {} latLng.lat = function() { return 45.52345150 } latLng.lng = function() { return -122.67620710 } return {latLng: latLng} } })