【问题标题】:Geo-location works in development not in production地理定位工作在开发中而不是在生产中
【发布时间】:2018-04-27 07:21:08
【问题描述】:

我正在使用以下脚本来管理地理位置,

<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

【问题讨论】:

    标签: javascript asp.net vb.net geolocation coordinates


    【解决方案1】:

    找到它,出于某种原因,ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "checkGPS", "checkGPS();", True) 不会在生产中触发,但 ClientScript.RegisterStartupScript(Me.GetType(), "checkGPS", "checkGPS();", True) 会。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-11
      • 2014-07-23
      • 1970-01-01
      • 1970-01-01
      • 2013-11-25
      • 2012-03-21
      • 1970-01-01
      • 2020-08-29
      相关资源
      最近更新 更多