2011-06-18 36 views
0

我試圖做一個網站,其中用戶將與他的黑莓9800示例遊覽用戶名和密碼登錄到網站。然後我想讓網頁使用黑莓的GPS來獲得座標。有人可以幫助我一些代碼。如何從登錄到網站時從黑莓GPS座標

預先感謝您。 M

回答

0

我想這兩個環節都和我的黑莓Curve(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

0

你可以嘗試這樣的事:

注*替換:YOUR_DESTINATION_ADDRESS在類似格式的地址:「147 +溫德姆+街道+ N +,+套房+ 206,+圭爾夫大學,+上, + 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>