Updated Branches: refs/heads/master 0634d0013 -> 6faf51d56
Fixes CB-450 - iOS Changes to Compass Update the doc to reflect that watchHeadingFilter and clearWatchFilter iOS only apis have been removed and are now supported as part of watchHeading and clearWatch. Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/commit/6faf51d5 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/tree/6faf51d5 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/diff/6faf51d5 Branch: refs/heads/master Commit: 6faf51d56e0538700ef0079c3b208b7d25062ef7 Parents: 0634d00 Author: Becky Gibson <becka...@apache.org> Authored: Fri Apr 6 08:57:27 2012 -0400 Committer: Becky Gibson <becka...@apache.org> Committed: Fri Apr 6 08:57:27 2012 -0400 ---------------------------------------------------------------------- .../cordova/compass/compass.clearWatchFilter.md | 86 +------------ docs/en/edge/cordova/compass/compass.md | 4 +- .../edge/cordova/compass/compass.watchHeading.md | 6 + .../cordova/compass/compass.watchHeadingFilter.md | 101 +-------------- .../cordova/compass/parameters/compassOptions.md | 2 +- 5 files changed, 11 insertions(+), 188 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/6faf51d5/docs/en/edge/cordova/compass/compass.clearWatchFilter.md ---------------------------------------------------------------------- diff --git a/docs/en/edge/cordova/compass/compass.clearWatchFilter.md b/docs/en/edge/cordova/compass/compass.clearWatchFilter.md index 44d200f..a8bc96e 100644 --- a/docs/en/edge/cordova/compass/compass.clearWatchFilter.md +++ b/docs/en/edge/cordova/compass/compass.clearWatchFilter.md @@ -1,88 +1,4 @@ compass.clearWatchFilter ======================== -Stop watching the compass referenced by the watch ID parameter. - - navigator.compass.clearWatchFilter(watchID); - -- __watchID__: The ID returned by `compass.watchHeadingFilter`. - -Supported Platforms -------------------- - -- iPhone - -Quick Example -------------- - - var watchID = navigator.compass.watchHeadingFilter(onSuccess, onError, options); - - // ... later on ... - - navigator.compass.clearWatchFilter(watchID); - -Full Example ------------- - - <!DOCTYPE html> - <html> - <head> - <title>Compass Example</title> - - <script type="text/javascript" charset="utf-8" src="cordova-1.6.0.js"></script> - <script type="text/javascript" charset="utf-8"> - - // The watch id references the current `watchHeading` - var watchID = null; - - // Wait for Cordova to load - // - document.addEventListener("deviceready", onDeviceReady, false); - - // Cordova is ready - // - function onDeviceReady() { - startWatch(); - } - - // Start watching the compass - // - function startWatch() { - - // Get notified on compass heading changes or 10 degrees or more - var options = { filter: 10 }; - - watchID = navigator.compass.watchHeadingFilter(onSuccess, onError, options); - } - - // Stop watching the compass - // - function stopWatch() { - if (watchID) { - navigator.compass.clearWatchFilter(watchID); - watchID = null; - } - } - - // onSuccess: Get the current heading - // - function onSuccess(heading) { - var element = document.getElementById('heading'); - element.innerHTML = 'Heading: ' + heading.magneticHeading; - } - - // onError: Failed to get the heading - // - function onError(compassError) { - alert('Compass error: ' + compassError.code); - } - - - </script> - </head> - <body> - <div id="heading">Waiting for heading...</div> - <button onclick="startWatch();">Start Watching via Filter</button> - <button onclick="stopWatch();">Stop Watching</button> - </body> - </html> +No longer supported as of 1.6. See `compass.clearWatch`. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/6faf51d5/docs/en/edge/cordova/compass/compass.md ---------------------------------------------------------------------- diff --git a/docs/en/edge/cordova/compass/compass.md b/docs/en/edge/cordova/compass/compass.md index 82470c5..25c8008 100755 --- a/docs/en/edge/cordova/compass/compass.md +++ b/docs/en/edge/cordova/compass/compass.md @@ -9,8 +9,8 @@ Methods - compass.getCurrentHeading - compass.watchHeading - compass.clearWatch -- compass.watchHeadingFilter -- compass.clearWatchFilter +- compass.watchHeadingFilter (obsolete) +- compass.clearWatchFilter (obsolete) Arguments --------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/6faf51d5/docs/en/edge/cordova/compass/compass.watchHeading.md ---------------------------------------------------------------------- diff --git a/docs/en/edge/cordova/compass/compass.watchHeading.md b/docs/en/edge/cordova/compass/compass.watchHeading.md index 71c9170..d5043a3 100755 --- a/docs/en/edge/cordova/compass/compass.watchHeading.md +++ b/docs/en/edge/cordova/compass/compass.watchHeading.md @@ -103,3 +103,9 @@ Full Example </body> </html> +iOS Quirks +-------------- + +In iOS `compass.watchHeading` can also get the device's current heading when it changes by a specified number of degrees. Each time the heading changes by the specified number of degrees or more, the `headingSuccess` callback function is called. Specify the degrees of change via the `filter` parameter in the `compassOptions` object. Clear the watch as normal by passing the returned watch ID to `compass.clearWatch`. This functionality replaces the previously separate, iOS only functions, watchHeadingFilter and clearWatchFilter, which were removed in 1.6. + +In iOS only one watchHeading can be in effect at one time. If a watchHeading via filter is in effect, calling getCurrentHeading or watchHeading will use the existing filter value for specifying heading changes. On iOS watching heading changes via a filter is more efficient than via time. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/6faf51d5/docs/en/edge/cordova/compass/compass.watchHeadingFilter.md ---------------------------------------------------------------------- diff --git a/docs/en/edge/cordova/compass/compass.watchHeadingFilter.md b/docs/en/edge/cordova/compass/compass.watchHeadingFilter.md index 2333d8f..bd4e784 100644 --- a/docs/en/edge/cordova/compass/compass.watchHeadingFilter.md +++ b/docs/en/edge/cordova/compass/compass.watchHeadingFilter.md @@ -1,103 +1,4 @@ compass.watchHeadingFilter ========================== -Get the compass heading in degrees when it changes by at least a certain number of degrees. - - var watchID = navigator.compass.watchHeadingFilter(compassSuccess, compassError, compassOptions); - -Description ------------ - -The compass is a sensor that detects the direction or heading that the device is pointed. It measures the heading in degrees from 0 to 359.99. - -The `compass.watchHeadingFilter` gets the device's current heading when it changes by a specified number of degrees. Each time the heading changes by the specified number of degrees or more, the `headingSuccess` callback function is called. Specify the degrees of change via the `filter` parameter in the `compassOptions` object. - -The returned watch ID references references the compass watch interval. The watch ID can be used with `compass.clearWatchFilter` to stop watching the compass via a degree filter. Only one watchHeadingFilter can be in effect at one time. If a watchHeadingFilter is in effect, calling getCurrentHeading or watchHeading will use the existing filter value for specifying heading changes. On iOS this method is more efficient than compass.watchFilter() based on the iOS mechanism for monitoring compass heading changes. - -Supported Platforms -------------------- - -- iPhone - - -Quick Example -------------- - - function onSuccess(heading) { - var element = document.getElementById('heading'); - element.innerHTML = 'Heading: ' + heading.magneticHeading; - }; - - function onError(compassError) { - alert('Compass error: ' + compassError.code); - }; - - var options = { filter: 10 }; // Get notified on compass heading changes or 10 degrees or more - - var watchID = navigator.compass.watchHeadingFilter(onSuccess, onError, options); - -Full Example ------------- - - <!DOCTYPE html> - <html> - <head> - <title>Compass Example</title> - - <script type="text/javascript" charset="utf-8" src="cordova-1.6.0.js"></script> - <script type="text/javascript" charset="utf-8"> - - // The watch id references the current `watchHeading` - var watchID = null; - - // Wait for Cordova to load - // - document.addEventListener("deviceready", onDeviceReady, false); - - // Cordova is ready - // - function onDeviceReady() { - startWatch(); - } - - // Start watching the compass - // - function startWatch() { - - // Get notified on compass heading changes or 10 degrees or more - var options = { filter: 10 }; - - watchID = navigator.compass.watchHeadingFilter(onSuccess, onError, options); - } - - // Stop watching the compass - // - function stopWatch() { - if (watchID) { - navigator.compass.clearWatchFilter(watchID); - watchID = null; - } - } - - // onSuccess: Get the current heading - // - function onSuccess(heading) { - var element = document.getElementById('heading'); - element.innerHTML = 'Heading: ' + heading.magneticHeading; - } - - // onError: Failed to get the heading - // - function onError(compassError) { - alert('Compass error: ' + compassError.code); - } - - </script> - </head> - <body> - <div id="heading">Waiting for heading...</div> - <button onclick="startWatch();">Start Watching via Filter</button> - <button onclick="stopWatch();">Stop Watching</button> - </body> - </html> - +No longer supported as of 1.6, see `compass.watchHeading` for equivalent functionality. http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/6faf51d5/docs/en/edge/cordova/compass/parameters/compassOptions.md ---------------------------------------------------------------------- diff --git a/docs/en/edge/cordova/compass/parameters/compassOptions.md b/docs/en/edge/cordova/compass/parameters/compassOptions.md index 38e8bda..fc203e2 100755 --- a/docs/en/edge/cordova/compass/parameters/compassOptions.md +++ b/docs/en/edge/cordova/compass/parameters/compassOptions.md @@ -7,7 +7,7 @@ Options ------- - __frequency:__ How often to retrieve the compass heading in milliseconds. _(Number)_ (Default: 100) -- __filter:__ The change in degrees required to initiate a watchHeadingFilter success callback. _(Number)_ +- __filter:__ The change in degrees required to initiate a watchHeading success callback. _(Number)_ Android Quirks ______________