0
我正在開發一個使用php和html-5的網站,我的計劃是在給定的JPEG圖像上顯示兩個位置之間的動態路由,我們如何能做到這一點,我不知道使用GPS系統,網站的想法,我想一些幫助..如何使用gps與php和html顯示動態路由
感謝
我正在開發一個使用php和html-5的網站,我的計劃是在給定的JPEG圖像上顯示兩個位置之間的動態路由,我們如何能做到這一點,我不知道使用GPS系統,網站的想法,我想一些幫助..如何使用gps與php和html顯示動態路由
感謝
尼斯文章在這裏:
http://merged.ca/iphone/html5-geolocation
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
function (position) {
// Did we get the position correctly?
// alert (position.coords.latitude);
// To see everything available in the position.coords array:
// for (key in position.coords) {alert(key)}
alert(position.coords.latitude + ',' + position.coords.longitude);
},
// next function is the error callback
function (error)
{
switch(error.code)
{
case error.TIMEOUT:
alert ('Timeout');
break;
case error.POSITION_UNAVAILABLE:
alert ('Position unavailable');
break;
case error.PERMISSION_DENIED:
alert ('Permission denied');
break;
case error.UNKNOWN_ERROR:
alert ('Unknown error');
break;
}
}
);
}
}
看到W3Schools的文章:http://www.w3schools.com/html/html5_geolocation.asp
if(!navigator.geolocation){
//the browser does not support geolocation
}else{
(function getPosition(){
navigator.geolocation.getCurrentPosition(
function (position){
//use the coordinates
balloon.style.left = (position.coords.latitude - latMin) * latScale;
balloon.style.top = (position.coords.longitude - longMin) * longScale;
//requery the position after a set time
setTimeout(getPosition,1000);
}
)
})()
}
['navigator.geolocation.getCurrentPosition'(http://www.w3schools.com/html/html5_geolocation.asp) –
@Jan德沃夏克:我們究竟如何可以使用這個 –
請參閱W3schools鏈接文章。您傳遞此方法的回調函數將獲取該位置作爲參數。 'getCurrentPosition'是異步的,因爲用戶可能必須首先批准地理定位。 –