I'm using following scripts to manage geo-location,
<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>
and the following code behind to trigger it
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
It works perfectly in development, it ask for permission to get position and then use the coordinates, but when I publish the site it ignores the function completely. I'm using chrome. Any hint/help would be much appreciated, thanks!
EDIT: the website where i'm publishing to uses https
出于某种原因找到了它,但ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "checkGPS", "checkGPS();", True)
在生产中不会触发,但是ClientScript.RegisterStartupScript(Me.GetType(), "checkGPS", "checkGPS();", True)
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.