Guest User

Simple Phonegap Build - index.html

a guest
Sep 22nd, 2013
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.76 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.   <head>
  4.     <title>Device Properties Example</title>
  5.  
  6.     <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
  7.     <script type="text/javascript" charset="utf-8">
  8.  
  9.     // Wait for Cordova to load
  10.     //
  11.     document.addEventListener("deviceready", onDeviceReady, false);
  12.  
  13.     // Cordova is ready
  14.     //
  15.     function onDeviceReady() {
  16.         navigator.geolocation.getCurrentPosition(onSuccess, onError);
  17.     }
  18.  
  19.     // onSuccess Geolocation
  20.     //
  21.     function onSuccess(position) {
  22.         var element = document.getElementById('geolocation');
  23.         element.innerHTML = 'Latitude: '           + position.coords.latitude              + '<br />' +
  24.                             'Longitude: '          + position.coords.longitude             + '<br />' +
  25.                             'Altitude: '           + position.coords.altitude              + '<br />' +
  26.                             'Accuracy: '           + position.coords.accuracy              + '<br />' +
  27.                             'Altitude Accuracy: '  + position.coords.altitudeAccuracy      + '<br />' +
  28.                             'Heading: '            + position.coords.heading               + '<br />' +
  29.                             'Speed: '              + position.coords.speed                 + '<br />' +
  30.                             'Timestamp: '          +                                   position.timestamp          + '<br />';
  31.     }
  32.  
  33.     // onError Callback receives a PositionError object
  34.     //
  35.     function onError(error) {
  36.         alert('code: '    + error.code    + '\n' +
  37.                 'message: ' + error.message + '\n');
  38.     }
  39.  
  40.     </script>
  41.   </head>
  42.   <body>
  43.     <p id="geolocation">Finding geolocation...</p>
  44.   </body>
  45. </html>
Add Comment
Please, Sign In to add comment