Skip to content

Instantly share code, notes, and snippets.

@arvi
Last active Dec 18, 2016
Embed
What would you like to do?
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