Add geolocation package

This commit is contained in:
Sashko Stubailo
2014-08-11 16:11:06 -07:00
parent 68725d5541
commit 33440ebd7a
4 changed files with 68 additions and 0 deletions

1
packages/geolocation/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.build*

View File

@@ -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;
}
};

View File

@@ -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");
});

View File

@@ -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"
}