I'm developing a page that uses geolocation and apparently everything works fine but in Safari version 11 I get an error geolocation My code is:
function initMap() {
var map;
var mapCenter;
var latit;
var lon;
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
latit = position.coords.latitude;
lon = position.coords.longitude;
mapCenter = new google.maps.LatLng(latit, lon);
console.log(mapCenter)
map = new google.maps.Map(document.getElementById('map'), {
center: mapCenter,
zoom: 15,
mapTypeControl: false,
fullscreenControl: true,
fullscreenControlOptions: {
position: google.maps.ControlPosition.RIGHT_BOTTOM
},
rotateControl: true,
scaleControl: true
});
var markerP = new google.maps.Marker({
position: mapCenter,
map: map,
title: 'Ubicacion actual',
animation: google.maps.Animation.DROP,
})
}, function (error) {
alert(error.code)
switch (error) {
case error.PERMISSION_DENIED:
alert("No se ha permitido acceso a la posición del usuario")
break;
case error.POSITION_UNAVAILABLE:
alert("No se ha permitido acceder a la información de la posicón")
break;
case error.TIMEOUT:
alert("El servicio ha tardado demaciado tiempo en responder")
break;
default:
alert("Error desconocido")
}
})
} else {
// Browser doesn't support Geolocation
}
}
}
when you get to the% share% share sends me to the error function indicating "Unknown error" but this only happens in Safari.
In safari version 9 if it works, but I can not find in the documentation something that will guide me since if I run safari a few times and nothing works.