登录网站时如何从黑莓获取GPS坐标

时间:2011-06-18 16:56:53

标签: javascript blackberry geolocation gps

我试图建立一个网站,用户将使用他的黑莓示例9800 tourch的用户名和密码登录网站。然后我希望网页使用Blackberry的GPS来获取坐标。有人可以用某种代码帮助我。

提前谢谢你。 中号

3 个答案:

答案 0 :(得分:1)

答案 1 :(得分:0)

我尝试了这两个链接,并且都在我的黑莓曲线(9330,OS 6.0)上返回经度和经度0,0。这非常令人失望,因为我一直在使用#2以上的其他设备。在挖了将近一天后,我发现这可以在我的黑莓上工作(虽然我无法让removeLocation处理程序工作。

<html>
<body>
<script language="Javascript">
function removeLocation() {
    // dummy function since removeLocationUpdate requires a callback
    window.alert("location handler removed");
}
function getLocation() {
    window.alert("Your new position is " + blackberry.location.latitude + " degrees latitude and " + blackberry.location.longitude + " degrees longitude.");
    blackberry.location.removeLocationUpdate(removeLocation);
}

if(blackberry.location.GPSSupported) {
blackberry.location.setAidMode(1);
blackberry.location.refreshLocation();
blackberry.location.onLocationUpdate(getLocation);
} else {
alert('nope');
}

</script>
<p>detecting location....</p>
</body>
</html>

使用此链接上一篇文章的帮助找到此脚本: http://www.blackberryforums.com/general-legacy-device-discussion/23544-7130e-gps-location-based-services-2.html

答案 2 :(得分:0)

您可以尝试这样的事情:

注意*替换:YOUR_DESTINATION_ADDRESS,地址格式如下:“147 + Wyndham + Street + N +,+ Suite + 206,+ Guelph,+ On,+ N1H + 4E9”

<div id="Map" style="width: 100%; height: 600px;"> </div>
<script type="text/javascript">
$(function(){
    var zoom = 11;
    function success(position) {

        var LAT = position.coords.latitude;
        var LONG = position.coords.longitude;
        $('#Map').append('<p>Current Latitude: ' + LAT + '<br/>Current Logitude: ' + LONG +'<br/><br/>Note* This may not display your exact location, but just your city. Works better on mobile devices</p>');


        var map  = '<iframe style="width: 100%; height: 600px;" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.ca/maps?source=s_d&saddr=' + LAT +',+' + LONG +'&daddr=**YOUR_DESTINATION_ADDRESS**&ie=UTF8&t=hz=' + zoom + '&output=embed"></iframe>';

        $('#Map').append(map);

    }

    function error(){
        /*Error Code*/
    }

    function MakeMap(){
        if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(success, error);
        } 
    }

    MakeMap();
});
</script>