Skip to content

Instantly share code, notes, and snippets.

@arvi
Last active December 18, 2016 07:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save arvi/a7354b5564a7dcf331e8960d6fa2a38b to your computer and use it in GitHub Desktop.
Save arvi/a7354b5564a7dcf331e8960d6fa2a38b to your computer and use it in GitHub Desktop.
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position){
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
var accuracy = position.coords.accuracy; console.log(latitude, longitude, accuracy); /*
var coords = new google.maps.LatLng(latitude, longitude);
var mapOptions = {
zoom: 15,
center: coords,
mapTypeControl: true,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.SMALL
},
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var capa = document.getElementById("capa");
capa.innerHTML = "latitud: " + latitude + " longitud: " + " aquesta es la precisio en metres : " + accuracy;
map = new google.maps.Map(
document.getElementById("mapContainer"), mapOptions
);
var marker = new google.maps.Marker({
position: coords,
map: map,
title: "ok"
});
*/
},function error(msg){alert('Please enable your GPS position future.');
}, {maximumAge:600000, timeout:5000, enableHighAccuracy: true});
}else {
alert("Geolocation API is not supported in your browser.");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment