Im trying to implement the geolocation services to get the latitude and longitude values, but in Safari it just doesnt work. And then in firefox it works, but it doesnt know how to handle errors. I have no idea why.
Below is my code.
<!DOCTYPE html>
<html lang="en">
<head>
<title>GPS</title>
</head>
<body>
<strong>Output:</strong>
<input type="text" id = "mapLink" value="">
<script type = "text/javascript">
navigator.geolocation.getCurrentPosition(showMap, handle_error);
function showMap(position){
var lat = position.coords.latitude;
var long = position.coords.longitude;
var linkUrl = lat + "," + long;
var mapLink = document.getElementById("mapLink");
mapLink.value = linkUrl;
}
function handle_error(err) {
alert('error');
}
</script>
</body>
</html>
Safari does support Geolocation. But to make your life easier, check out http://code.google.com/p/geo-location-javascript/.