Wikipedia para siempre
ShareCode
Permalink: http://www.treeweb.es/u/974/ 01/02/2011

ShareCode

1 addEventListener('load', function(e) {2 3  var needle = document.getElementById('compass-needle');4 5 6  // Prepare compass7  if (window.DeviceOrientationEvent) {8  // DeviceOrientation is supported9  window.addEventListener('deviceorientation', function(e) {10  needle.style.webkitTransform = 'rotate('+Math.floor(e.alpha)+'deg)';11  }, false);12  } else if (window.OrientationEvent) {13  //MozOrientation is supported");14  }15  16  // Prepare geolocation17  if (navigator.geolocation) { 18  var geo = navigator.geolocation.getCurrentPosition(19  function(msg) {20  lat = msg.coords.latitude;21  lon = msg.coords.longitude;22  zoom = 16;23  24  url = 'http://maps.googleapis.com/maps/api/staticmap?center='+lat+','+lon+'&zoom='+zoom+'&size=600x300&maptype=roadmap&markers=color:blue|label:S|'+lat+','+lon+'&sensor=false';25 26  needle.style.backgroundImage = 'url('+url+')';27  },28  function(msg) {29  // logger.log({error:msg});30  }31  );32  } else {33  alert('Sorry, your browser does not support Geolocation.')34  } 35  36 }, true);37 38 
Enlace
El enlace para compartir es: