久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      HTML5-Geolocation APIs的示例代碼

      1.navigator.geolocation
      HTML5中的地理位置相關(guān)的主要對象是navigator.geolocation,它有一些方法和屬性,檢測瀏覽器對HTML5地理位置的支持性也就是檢測該對象。

      2.getCurrentPosition、watchPosition和clearWatch方法
      這是geolocation的兩個核心方法。第一個方法只獲取地理位置信息,后一個方法以一定時間間隔獲取地理位置信息,它們的參數(shù)相同,但返回值不同,后者返回一個watchId,將watchId作為參數(shù)傳遞給clearWatch方法可以終止對地理位置信息的請求。
      getCurrentPosition形如:

      void getCurrentPosition(in PositionC  all  back successCallback,                              in optional PositionErrorCallback errorCallback,                              in optional PositionOptions options);

      第一個參數(shù)是一個函數(shù),用于處理成功接收到的地理位置信息,它通常接收一個position對象作為參數(shù),并提供接收到的地理位置信息。
      第二格參數(shù)是可選的,也是一個函數(shù),用于錯誤處理,該函數(shù)通常接收一個error對象作為參數(shù),error含有錯誤信息。
      第三個參數(shù)用于進一步控制地理位置信息,也是可選的。它通常用花括號括起來,它通常有三個值:
      enableHighAccuracy:用于控制精度,它的效果可能會有副作用。
      timeout:用于指定地理位置信息請求的超時時間,單位是毫秒。
      maximumAge:用于指定地理位置信息的更新頻率,單位是毫秒。

      一個示例如下:

      navigator.geolocation.getCurrentPosition(up  date  Location,han  dl  eLocationError,                                            {timeout:10000});

      3.psition對象
      其定義如下:

      interface Position {        readonly attribute Co  ord  inates coords;        readonly attribute DOMTimeStamp timestamp;     };

      它有一個子對象coords和一個屬性timestamp。
      coords:是一個Coordinates對象,其定義如下:

         interface Coordinates {           readonly attribute double latitude; //維度           readonly attribute double lon  git  ude; //經(jīng)度           readonly attribute double? altitude; //高程(/m)           readonly attribute double accuracy; //經(jīng)度和維度的精確度(/m)           readonly attribute double? altitudeAccuracy; //高程精確度(/m)           readonly attribute double?   head  ing; //移動方向(/deg)           readonly attribute double? speed; //移動速度(/m/s)        };

      其中帶問號的屬性在許多瀏覽器和設(shè)備中不會實現(xiàn),如果沒有這些屬性,通過編程 獲取的值將是null。
      latitude,longitude和accuracy三個屬性,分別用于提供請求到的維度,經(jīng)度和精 度信息。經(jīng)緯度用小數(shù)表示,精度單位是米。

      timestamp:時間戳。

      4.error對象
      error對象有一個code屬性,用于指定錯誤類型,可以認為code是一個枚舉類型,它有四個值:0(UNKNOWN_ERROR1,1(PERMISSION_DENIED),2(POSITION_UNAVAILABLE)和
      3(TIMEOUT)。
      另外,error還有一個message屬性,用于提供錯誤的詳細信息。

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號