GPS坐标不会出现在智能手机中

时间:2021-01-03 09:07:57

标签: gps coordinates

我有这个代码来获取 GPS 坐标到文本框

    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=API_Key"></script>
 
<script type="text/javascript">
    function ViewCoOrdinate() {
        if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(function (p) {
                var lat = p.coords.latitude;
                var lng = p.coords.longitude;
                document.getElementById("txtLoc").value = lat +','+ lng;
            });
        } else {
            alert('Geo Location feature is not supported in this browser.');
        }
  
        return false;
    }
        </script>

<asp:TextBox ID="txtLoc" runat="server" CssClass="auto-style14"></asp:TextBox>
<asp:Button ID="btnView" runat="server" Text="View" onclientclick="return ViewCoOrdinate()" />

但它只能通过笔记本电脑工作 它不能通过智能手机或 PC 工作 即使在手机中打开 GPS 后

0 个答案:

没有答案
相关问题