Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 21st, 2012  |  syntax: None  |  size: 1.43 KB  |  hits: 56  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.         <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
  5.         <meta http-equiv="Content-type" content="text/html; charset=utf-8">
  6.  
  7.         <script type="text/javascript" charset="utf-8" src="phonegap-1.0.0.js"></script>
  8.     <script type="text/javascript" charset="utf-8">
  9.  
  10.         function onBodyLoad() {        
  11.                 document.addEventListener("deviceready", onDeviceReady, false);
  12.         }
  13.        
  14.         function onDeviceReady() {
  15.                 navigator.geolocation.getCurrentPosition(onPhoneGapGeolocationSuccess, onPhoneGapError);
  16.  
  17.             var timeInSeconds = 45 * 1000;
  18.                 var options = { maximumAge: timeInSeconds/2.0, timeout: timeInSeconds, enableHighAccuracy: true };
  19.                 navigator.geolocation.watchPosition(onPhoneGapWatchSuccess, onPhoneGapError, options);
  20.         }
  21.  
  22.         function onPhoneGapGeolocationSuccess(position) {
  23.                 var newLat = position.coords.latitude,
  24.                 newLon = position.coords.longitude,
  25.                 newHeading = position.coords.heading;
  26.  
  27.                 console.log('onPhoneGapGeolocationSuccess: [' + newLat + '|' + newLon + '] + '+ newHeading);
  28.         }
  29.  
  30.         function onPhoneGapError(error) {
  31.                 console.log('Status: ' + error.code + '|' +  error.message);
  32.         }        
  33.  
  34.         onPhoneGapWatchSuccess = function(position) {
  35.                 var newLat = position.coords.latitude,
  36.                 newLon = position.coords.longitude;
  37.  
  38.                 console.log('onPhoneGapWatchSuccess: [' + newLat + '|' + newLon + ']');
  39.         }
  40.  
  41.         </script>
  42. </head>
  43. <body onload="onBodyLoad()">
  44.         <h1>Location Test</h1>
  45. </body>
  46. </html>