Created
March 21, 2013 22:08
-
-
Save loris/5217237 to your computer and use it in GitHub Desktop.
Simple HTML5 page that redirect the user to Google Maps showing directions from its location (using HTML5 geolocation) to the place set as query parameter (ie, map-direction.html?Empire+State+Building+NYC). Useful in Alfred WebSearch.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<script> | |
var daddr = window.location.search.slice(1); | |
if (navigator.geolocation) { | |
navigator.geolocation.getCurrentPosition(function(data){ | |
if (data.coords) { | |
window.location = 'https://maps.google.fr/maps?saddr=' + data.coords.latitude + ',' + data.coords.longitude + '&daddr=' + daddr; | |
} | |
}); | |
} | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment