diff --git a/packages/geolocation/.gitignore b/packages/geolocation/.gitignore new file mode 100644 index 0000000000..677a6fc263 --- /dev/null +++ b/packages/geolocation/.gitignore @@ -0,0 +1 @@ +.build* diff --git a/packages/geolocation/geolocation.js b/packages/geolocation/geolocation.js new file mode 100644 index 0000000000..e8bb2e6b86 --- /dev/null +++ b/packages/geolocation/geolocation.js @@ -0,0 +1,32 @@ +var locationDep = new Deps.Dependency(); +var location = null; +var locationRefresh = false; + +var options = { + enableHighAccuracy: true, + maximumAge: 0 +}; + +var errCallback = function () { + // do nothing +}; + +var callback = function (newLocation) { + location = newLocation; + locationDep.changed(); +}; + +var enableLocationRefresh = function () { + if (! locationRefresh && navigator.geolocation) { + navigator.geolocation.watchPosition(callback, errCallback, options); + locationRefresh = true; + } +}; + +Geolocation = { + currentLocation: function () { + enableLocationRefresh(); + locationDep.depend(); + return location; + } +}; \ No newline at end of file diff --git a/packages/geolocation/package.js b/packages/geolocation/package.js new file mode 100644 index 0000000000..91724961bc --- /dev/null +++ b/packages/geolocation/package.js @@ -0,0 +1,16 @@ +Package.describe({ + summary: "Provides reactive geolocation on desktop and mobile.", + version: "1.0.0" +}); + +Cordova.depends({ + "org.apache.cordova.geolocation": "0.3.9" +}); + +Package.on_use(function (api) { + api.use(["deps"]); + + api.add_files(["geolocation.js"], "client"); + + api.export("Geolocation", "client"); +}); \ No newline at end of file diff --git a/packages/geolocation/versions.json b/packages/geolocation/versions.json new file mode 100644 index 0000000000..f90d6d0090 --- /dev/null +++ b/packages/geolocation/versions.json @@ -0,0 +1,19 @@ +{ + "dependencies": [ + [ + "deps", + "1.0.0" + ], + [ + "meteor", + "1.0.0" + ], + [ + "underscore", + "1.0.0" + ] + ], + "pluginDependencies": [], + "toolVersion": "meteor-tool@1.0.0", + "format": "1.0" +} \ No newline at end of file