Advertisement
Guest User

Untitled

a guest
Apr 27th, 2015
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <widget xmlns = "http://www.w3.org/ns/widgets"
  3. xmlns:gap = "http://phonegap.com/ns/1.0"
  4. id = "......"
  5. version = "1.0.0" >
  6.  
  7. <name>.....</name>
  8.  
  9. <preference name="permissions" value="none"/>
  10.  
  11. <preference name="orientation" value="default" />
  12. <preference name="target-device" value="universal" />
  13. <preference name="phonegap-version" value="3.6.3" />
  14.  
  15. <gap:plugin name="org.apache.cordova.geolocation" />
  16. <gap:plugin name="com.phonegap.plugins.PushPlugin" version="2.4.0" />
  17. <gap:plugin name="org.apache.cordova.network-information" />
  18. <gap:plugin name="org.apache.cordova.statusbar" />
  19. <gap:plugin name="org.apache.cordova.device" />
  20. <gap:plugin name="org.transistorsoft.cordova.background-geolocation"/>
  21. </widget>
  22.  
  23. navigator.geolocation.getCurrentPosition(function (position) {
  24. .....
  25. }, function (error) {}, {
  26. enableHighAccuracy: true,
  27. maximumAge: 30000,
  28. timeout: 10000
  29. });
  30.  
  31. var minAccuracyInMetres = 50;
  32.  
  33. var positionWatcher;
  34.  
  35. function onDeviceReady(){
  36. positionWatcher = navigator.geolocation.watchPosition(
  37. geolocationSuccess,
  38. geolocationError,
  39. {maximumAge:0, timeout: 10000, enableHighAccuracy: true});
  40. }
  41.  
  42. function geolocationSuccess(position){
  43. // Reject if accuracy is not sufficient
  44. if(position.coords.accuracy > minAccuracyInMetres){
  45. return;
  46. }
  47.  
  48. // Only single position required so clear watcher
  49. navigator.geolocation.clearWatch(positionWatcher);
  50.  
  51. // Do something with the user's location...
  52.  
  53. }
  54.  
  55. function geolocationError(error){
  56. console.warn("Error while retrieving current position. " +
  57. "Error code: " + error.code + ",Message: " + error.message);
  58. }
  59.  
  60. document.addEventListener("deviceready", onDeviceReady, false);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement