如何防止 Firefox 在每次请求时都要求用户分享他们的位置?
我正在使用谷歌地图 API。下面是我分享位置的代码。在 Firefox 中,它总是要求与下面的弹出窗口共享位置。每次都会发生这种情况,无论我点击Share还是Not Now。
下面是我的代码
<% if (!Page.IsPostBack)
{ %>
// opened the share location
if (navigator.geolocation)
{
try
{
navigator.geolocation.getCurrentPosition(onPositionUpdate);
}
catch (err)
{
alert(err);
}
}
else
{
alert("You location is not available. Please enter your location to continue!");
}
<%}%>
function onPositionUpdate(position)
{
var lat = position.coords.latitude;
var lng = position.coords.longitude;
try
{
var latLng = new google.maps.LatLng(lat, lng);
if (marker == null)
{
alert("Sorry we are not able to update your location.");
}
else
{
setTimeout(function ()
{
marker.setPosition(latLng);
map.setCenter(latLng);
document.getElementById('ctl00_ContentPlaceHolderBody_latSel').value = lat;
document.getElementById('ctl00_ContentPlaceHolderBody_lngSel').value = lng;
geocodePosition(latLng);
}, 100);
}
}
catch (err)
{
alert(err);
}
}