mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Add geolocation package
This commit is contained in:
1
packages/geolocation/.gitignore
vendored
Normal file
1
packages/geolocation/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.build*
|
||||
32
packages/geolocation/geolocation.js
Normal file
32
packages/geolocation/geolocation.js
Normal 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;
|
||||
}
|
||||
};
|
||||
16
packages/geolocation/package.js
Normal file
16
packages/geolocation/package.js
Normal 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");
|
||||
});
|
||||
19
packages/geolocation/versions.json
Normal file
19
packages/geolocation/versions.json
Normal 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"
|
||||
}
|
||||
Reference in New Issue
Block a user