国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Html5 geographical positioning

HTML5 Geolocation

HTML5 Geolocation is used to locate the user's location.

Positioning the position of the user

## HTML5 Geolocation API is used to obtain the user's geographical location.

Given that this feature may violate user privacy, user location information is not available unless the user agrees.

# browser supports


Aterent Explorer 9+, Firefox, Chrome, Safari and Opera support Geolocation (geographical positioning).

Note: Geolocation (geographical positioning) For devices with GPS, such as iPhone, geographical positioning is more accurate.

Qi test whether the browser supports:

if (navigator.geolocation) { 
   //console.log("瀏覽器支持!"); 
   }else { 
      // console.log("瀏覽器不支持!");
 }

Navigator.Geolocation is used to obtain the current user geographical location of the browser -based, provided 3 Method:

RrreerReee Handling errors and rejection of

# stertcurrentposition () method for handling errors. It specifies the function to be run when obtaining the user's location fails:

Instance

void getCurrentPosition(onSuccess,onError,options);//獲取用戶(hù)當(dāng)前位置
int watchCurrentPosition(onSuccess,onError,options);//持續(xù)獲取當(dāng)前用戶(hù)位置
void clearWatch(watchId);//watchId 為watchCurrentPosition返回的值//取消監(jiān)控

###
Continuing Learning
||
<!DOCTYPE html> <html> <head>  <meta charset="utf-8">  <title>php中文網(wǎng)(php.cn)</title>  </head> <body> <p id="demo">點(diǎn)擊按鈕獲取您當(dāng)前坐標(biāo)(可能需要比較長(zhǎng)的時(shí)間獲取):</p> <button onclick="getLocation()">點(diǎn)我</button> <script> var x=document.getElementById("demo"); function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition,showError); } else{x.innerHTML="Geolocation is not supported by this browser.";} } function showPosition(position) { x.innerHTML="緯度: " + position.coords.latitude + "<br>經(jīng)度: " + position.coords.longitude; } function showError(error) { switch(error.code) { case error.PERMISSION_DENIED: x.innerHTML="用戶(hù)拒絕對(duì)獲取地理位置的請(qǐng)求。" break; case error.POSITION_UNAVAILABLE: x.innerHTML="位置信息是不可用的。" break; case error.TIMEOUT: x.innerHTML="請(qǐng)求用戶(hù)地理位置超時(shí)。" break; case error.UNKNOWN_ERROR: x.innerHTML="未知錯(cuò)誤。" break; } } </script> </body> </html>
submitReset Code