-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the ability to tweak the PositionOptions used for Geolocation, for instance to use low-accuracy position to save battery on mobile devices. The options parameter is reactive. Add a `pause` feature to temporarily halt position updates, again to allow better power management on mobile devices. The paused status is also reactive. Stop position watcher when there are no dependencies of the location, so that we automatically save power if (for example) a reactive map view is not visible.
- Loading branch information
Showing
6 changed files
with
104 additions
and
22 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ [email protected] | |
[email protected] | ||
[email protected] | ||
[email protected] | ||
mdg:[email protected].2 | ||
mdg:[email protected].3 | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,22 @@ | ||
if (Meteor.isClient) { | ||
Template.body.events({ | ||
"change .high-accuracy input": function (event) { | ||
Session.set("highAccuracy", event.target.checked); | ||
} | ||
}); | ||
Template.body.helpers({ | ||
loc: function () { | ||
// options is *optional*. We're including it in this demo | ||
// to show how it is reactive. | ||
var options = { | ||
enableHighAccuracy: !!Session.get("highAccuracy") | ||
}; | ||
// return 0, 0 if the location isn't ready | ||
return Geolocation.latLng() || { lat: 0, lng: 0 }; | ||
return Geolocation.latLng(options) || { lat: 0, lng: 0 }; | ||
}, | ||
error: Geolocation.error | ||
error: Geolocation.error, | ||
highAccuracy: function() { | ||
return Session.get("highAccuracy"); | ||
} | ||
}); | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
Package.describe({ | ||
name: "mdg:geolocation", | ||
summary: "Provides reactive geolocation on desktop and mobile.", | ||
version: "1.0.2", | ||
version: "1.0.3", | ||
git: "https://github.com/meteor/mobile-packages" | ||
}); | ||
|
||
|
@@ -14,4 +14,4 @@ Package.on_use(function (api) { | |
api.versionsFrom("[email protected]"); | ||
api.add_files(["geolocation.js"], "client"); | ||
api.export("Geolocation", "client"); | ||
}); | ||
}); |