]>
git.proxmox.com Git - extjs.git/blob - extjs/packages/legacy/modern/src/device/Compass.js
2 * Provides access to the native Compass API when running on a device. There are three implementations of this API:
4 * - [PhoneGap](http://docs.phonegap.com/en/2.6.0/cordova_compass_compass.md.html#Compass)
6 * This class will automatically select the correct implementation depending on the device your application is running on.
10 * Getting the current location:
12 * Ext.device.Compass.getCurrentHeading({
13 * success: function(heading) {
14 * alert('Heading: ' + heading.magneticHeading);
16 * failure: function() {
17 * console.log('something went wrong!');
21 * Watching the current compass:
23 * Ext.device.Compass.watchHeading({
24 * frequency: 500, // Update every 1/2 second
25 * callback: function(heading) {
26 * console.log('Heading: ' + heading.magneticHeading);
28 * failure: function() {
29 * console.log('something went wrong!');
33 * @mixins Ext.device.compass.Abstract
35 Ext
.define('Ext.device.Compass', {
39 'Ext.device.compass.Cordova',
40 'Ext.device.compass.Simulator'
43 constructor: function() {
44 var browserEnv
= Ext
.browser
.is
;
45 if (browserEnv
.WebView
&& browserEnv
.Cordova
) {
46 return Ext
.create('Ext.device.compass.Cordova');
49 return Ext
.create('Ext.device.compass.Simulator');