]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | /**\r |
2 | * Provides access to the native Geolocation API when running on a device. There are three implementations of this API:\r | |
3 | *\r | |
4 | * - Sencha Packager\r | |
5 | * - [PhoneGap](http://docs.phonegap.com/en/1.4.1/phonegap_device_device.md.html)\r | |
6 | * - Browser\r | |
7 | *\r | |
8 | * This class will automatically select the correct implementation depending on the device your application is running on.\r | |
9 | *\r | |
10 | * ## Examples\r | |
11 | *\r | |
12 | * Getting the current location:\r | |
13 | *\r | |
14 | * Ext.device.Geolocation.getCurrentPosition({\r | |
15 | * success: function(position) {\r | |
16 | * console.log(position.coords);\r | |
17 | * },\r | |
18 | * failure: function() {\r | |
19 | * console.log('something went wrong!');\r | |
20 | * }\r | |
21 | * });\r | |
22 | *\r | |
23 | * Watching the current location:\r | |
24 | *\r | |
25 | * Ext.device.Geolocation.watchPosition({\r | |
26 | * frequency: 3000, // Update every 3 seconds\r | |
27 | * callback: function(position) {\r | |
28 | * console.log('Position updated!', position.coords);\r | |
29 | * },\r | |
30 | * failure: function() {\r | |
31 | * console.log('something went wrong!');\r | |
32 | * }\r | |
33 | * });\r | |
34 | *\r | |
35 | * @mixins Ext.device.geolocation.Abstract\r | |
36 | */\r | |
37 | Ext.define('Ext.device.Geolocation', {\r | |
38 | singleton: true,\r | |
39 | \r | |
40 | requires: [\r | |
41 | 'Ext.device.Communicator',\r | |
42 | 'Ext.device.geolocation.Cordova',\r | |
43 | 'Ext.device.geolocation.Simulator'\r | |
44 | ],\r | |
45 | \r | |
46 | constructor: function() {\r | |
47 | var browserEnv = Ext.browser.is;\r | |
48 | if (browserEnv.WebView) {\r | |
49 | if (browserEnv.Cordova) {\r | |
50 | return Ext.create('Ext.device.geolocation.Cordova');\r | |
51 | }\r | |
52 | }\r | |
53 | \r | |
54 | return Ext.create('Ext.device.geolocation.Simulator');\r | |
55 | }\r | |
56 | });\r |