【问题标题】:Geolocation on smartphone devices doesn't run智能手机设备上的地理位置无法运行
【发布时间】:2016-03-03 09:00:38
【问题描述】:

在我的网站上,当我点击一个按钮时,我必须启动谷歌地图以获取行车路线。我知道终点,但我必须用地理位置传达起点,这是我的位置。 我在智能手机设备上遇到地理定位问题。 这是我的代码:

jQuery(window).load(function(){ if (navigator.geolocation) navigator.geolocation.getCurrentPosition(function(position){ myLat=position.coords.latitude; myLng=position.coords.longitude; jQuery(".btn").attr("href", "http://www.google.it/maps?saddr="+myLat+","+myLng+"&daddr=44.000000,7.000000")}; }); });

它在电脑上运行良好,但在智能手机上却无法运行。发生错误。我应该为这些设备写一个不同的href吗?如果是这样,怎么办?? 非常感谢您的帮助!!

【问题讨论】:

    标签: javascript google-maps geolocation driving-directions


    【解决方案1】:

    我想我解决了。 我检测我是否正在使用移动设备并为他们使用此代码

    if( isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows()){
            jQuery(".btn").attr("href", "https://maps.google.com?saddr=Current+Location&daddr=44.000000,7.000000")
        }
    

    感谢您对里卡多的支持

    【讨论】:

      【解决方案2】:

      看看这里是否对你有帮助。 http://www.w3schools.com/html/html5_geolocation.asp

      【讨论】:

        猜你喜欢
        • 2018-01-29
        • 2018-03-21
        • 1970-01-01
        • 2015-05-21
        • 1970-01-01
        • 1970-01-01
        • 2012-03-21
        • 1970-01-01
        • 2018-12-26
        相关资源
        最近更新 更多