我正在使用以下脚本来管理地理位置,
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDfql15EdzdP0dJZ_r5A8IHs46KsJSIsbk&sensor=false"></script>
<script type="text/javascript">
function checkGPS() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (p) {
var LatLng = new google.maps.LatLng(p.coords.latitude, p.coords.longitude);
var mapOptions = {
center: LatLng,
zoom: 13,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);
var marker = new google.maps.Marker({
position: LatLng,
map: map,
title: "Latitudine: " + p.coords.latitude + "<br />Longitudine: " + p.coords.longitude
});
document.getElementById('<%=latitudine.ClientID %>').value = p.coords.latitude;
document.getElementById('<%=longitudine.ClientID %>').value = p.coords.longitude;
window.AppInventor.setWebViewString("latitudine" + p.coords.latitude + "&longitudine" + p.coords.longitude)
google.maps.event.addListener(marker, "click", function (e) {
var infoWindow = new google.maps.InfoWindow();
infoWindow.setContent(marker.title);
infoWindow.open(map, marker);
});
});
} else {
alert('Attenzione, il tuo browser non supporta la geolocalizzazione, non è possibile continuare.');
}
}
</script>
以及后面的代码来触发它
idDipendente = Session("idUtente")
idCliente = Session("rfCliente")
If idDipendente <> 0 Then
Dim dipendente As Utenti = db.Utenti.Where(Function(u) u.IdUtente = idDipendente).SingleOrDefault
Dim cliente As Clienti = db.Clienti.Where(Function(c) c.IdCliente = idCliente).SingleOrDefault
If cliente.Geolocalizzazione Then
If dipendente.Geolocalizzazione Then
ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "checkGPS", "checkGPS();", True)
End If
End If
End If
它在开发中完美运行,它要求获得位置的许可然后使用坐标,但是当我发布网站时它完全忽略了该功能。我正在使用铬。任何提示/帮助将非常感谢,谢谢!
编辑:我发布的网站使用https
答案 0 :(得分:0)
找到它,由于某种原因,ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "checkGPS", "checkGPS();", True)
不会在生产中触发,但ClientScript.RegisterStartupScript(Me.GetType(), "checkGPS", "checkGPS();", True)
会触发。