PositionOptions
PositionOptions
是一個當作 Geolocation.getCurrentPosition()
以及 Geolocation.watchPosition()
參數的物件,此物件含有幾種可以設定的屬性。
屬性
PositionOptions
介面沒有繼承任何屬性
PositionOptions.enableHighAccuracy
- 是一個
Boolean
(en-US) 的值。此值指出方法是否需要回傳最佳的結果。如果值為真且該裝置具備提供精準位置的能力,則方法會回傳最佳結果。必須注意的是最佳結果會導致較長的回應時間或者需要更多的電力耗損 (舉例來說擁有GPS晶片的手機)。相反來說,如果值為偽,機器會因為回應時間較短以及消耗較少的電力達到資源節省
。預設值:偽。 PositionOptions.timeout
- 這是一個正值,它代表機器能夠等待方法回傳位置的最長時間(單位是毫秒)。預設值是
Infinity
,代表getCurrentPosition()
此方法在沒有可用的位置前不會有任何回覆。 PositionOptions.maximumAge
- 這是一個正值,它代表可以接受暫存位置的最長時限(單位是毫秒)。如果設定為 0,代表機器必須回傳實際的當前位置而不能使用暫存位置。如果設定為
Infinity
,機器必定會回傳暫存位置而不考慮他的時限。預設值:0。
方法
PositionOptions
介面沒有實現也沒有繼承任何方法。
規格
Specification | Status | Comment |
---|---|---|
Geolocation API The definition of 'PositionOptions' in that specification. |
Recommendation | Initial definition |
瀏覽器的相容性
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help! (en-US)
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | 5 | 3.5 (1.9.1) | 9 | 10.60 No support 15.0 16.0 |
5 |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | ? | ? | 4.0 (4) | ? | 10.60 | ? |
請參考
- Using geolocation
Geolocation
介面使用此物件。