提问人:Gabriele Cozzolino 提问时间:4/27/2018 最后编辑:braXGabriele Cozzolino 更新时间:4/27/2018 访问量:96
地理位置工作在开发中,而不是在生产中
Geo-location works in development not in production
问:
我正在使用以下脚本来管理地理位置,
<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
它在开发中完美运行,它要求获得位置的许可,然后使用坐标,但是当我发布网站时,它完全忽略了该功能。我正在使用 chrome。任何提示/帮助将不胜感激,谢谢!
编辑:我要发布到的网站使用https
答:
0赞
Gabriele Cozzolino
4/27/2018
#1
找到了它,由于某种原因没有在生产中触发,但确实如此。ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "checkGPS", "checkGPS();", True)
ClientScript.RegisterStartupScript(Me.GetType(), "checkGPS", "checkGPS();", True)
评论