0

Scripts run on locationfound but not on locationerror. locationerror is true when the user don't accept to share his position, wright?

If the user give his agreement, alert('ok') is done. If he don't give his agreement, alert('error') is not done. Someone's knows why?

var map = L.map('map')

L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'}).addTo(map);

map.locate({setView: true, maxZoom: 10});

map.on('locationfound', function() {
    alert('ok');
});

map.on('locationerror', function() {
    alert('error');
    map.setView(45.0681298, 7.6059589, 10);
});

0 Answers0