mozilla

Revision 458269 of PositionOptions

  • Revision slug: Web/API/PositionOptions
  • Revision title: PositionOptions
  • Revision id: 458269
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment

Revision Content

A PositionOptions object is an interface describing the options to use when calling the geolocation backend. The user agent itself doesn't create such an object itself: it is the calling script that create it and use it as a parameter of {{domxref("Geolocation.getCurrentPosition()")}} and {{domxref("Geolocation.watchPosition()"}}.

Properties

The PositionOptions interface doesn't inherit any property.

{{domxref("PositionOptions.enableHighAccuracy")}}
Is a {{domxref("Boolean")}} that indicates the application would like to receive the best possible results. If true and if the device is able to provide a more accurate position, it will do so. Note that this can result in slower response times or increased power consumption (with a GPS chip on a mobile device for example). On the other hand, if false (the default value), the device can take the liberty to save resources by responding more quickly and/or using less power.
{{domxref("PositionOptions.timeout")}}
Is a positive long value representing the maximum length of time (in milliseconds) the device is allowed to take in order to return a position. The default value is Infinity, meaning that getCurrentPosition() won't return until the position is available.
{{domxref("PositionOptions.maximumAge")}}
Is a positive long value indicating the maximum age in milliseconds of a possible cached position that is acceptable to return. If set to 0, it means that the device cannot use a cached position and must attempt to retrieve the real current position. If set to Infinity the device must return a cached position regardless of its age.

Methods

The PositionOptions interface neither implements, nor inherit any method.

Specifications

Specification Status Comment
{{SpecName('Geolocation', '#positionoptions', 'PositionOptions')}} {{Spec2('Geolocation')}} Initial specification.

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 5 {{CompatGeckoDesktop("1.9.1")}} 9 10.60
Removed in 15.0
Reintroduced in 16.0
5
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatUnknown()}} {{CompatUnknown()}} {{CompatGeckoMobile("4")}} {{CompatUnknown()}} 10.60 {{CompatUnknown()}}

See also

Revision Source

<p>A <strong><code>PositionOptions</code></strong> object is an interface describing the options to use when calling the geolocation backend. The user agent itself doesn't create such an object itself: it is the calling script that create it and use it as a parameter of {{domxref("Geolocation.getCurrentPosition()")}} and {{domxref("Geolocation.watchPosition()"}}.</p>
<h2 id="Properties">Properties</h2>
<p><em>The <code>PositionOptions</code> interface </em><em><em>doesn't inherit any property</em></em>.</p>
<dl>
  <dt>
    {{domxref("PositionOptions.enableHighAccuracy")}}</dt>
  <dd>
    Is a {{domxref("Boolean")}} that indicates the application would like to receive the best possible results. If <code>true</code> and if the device is able to provide a more accurate position, it will do so. Note that this can result in slower response times or increased power consumption (with a GPS chip on a mobile device for example). On the other hand, if <code>false</code> (the default value), the device can take the liberty to save resources by responding more quickly and/or using less power.</dd>
  <dt>
    {{domxref("PositionOptions.timeout")}}</dt>
  <dd>
    Is a positive <code>long</code> value representing the maximum length of time (in milliseconds) the device is allowed to take in order to return a position. The default value is <code><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Infinity" title="/en-US/docs/JavaScript/Reference/Global_Objects/Infinity">Infinity</a></code>, meaning that <code>getCurrentPosition()</code> won't return until the position is available.</dd>
  <dt>
    {{domxref("PositionOptions.maximumAge")}}</dt>
  <dd>
    Is a positive <code>long</code> value indicating the maximum age in milliseconds of a possible cached position that is acceptable to return. If set to <code>0</code>, it means that the device cannot use a cached position and must attempt to retrieve the real current position. If set to <code><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Infinity" title="/en-US/docs/JavaScript/Reference/Global_Objects/Infinity">Infinity</a></code> the device must return a cached position regardless of its age.</dd>
</dl>
<h2 id="Methods">Methods</h2>
<p><em><em>The <code>PositionOptions</code> interface <em>neither implements, nor inherit any method.</em></em></em></p>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
  <thead>
    <tr>
      <th scope="col">Specification</th>
      <th scope="col">Status</th>
      <th scope="col">Comment</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>{{SpecName('Geolocation', '#positionoptions', 'PositionOptions')}}</td>
      <td>{{Spec2('Geolocation')}}</td>
      <td>Initial specification.</td>
    </tr>
  </tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Chrome</th>
        <th>Firefox (Gecko)</th>
        <th>Internet Explorer</th>
        <th>Opera</th>
        <th>Safari</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>5</td>
        <td>{{CompatGeckoDesktop("1.9.1")}}</td>
        <td>9</td>
        <td>10.60<br />
          Removed in 15.0<br />
          Reintroduced in 16.0</td>
        <td>5</td>
      </tr>
    </tbody>
  </table>
</div>
<div id="compat-mobile">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Android</th>
        <th>Chrome for Android</th>
        <th>Firefox Mobile (Gecko)</th>
        <th>IE Mobile</th>
        <th>Opera Mobile</th>
        <th>Safari Mobile</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{CompatUnknown()}}</td>
        <td>{{CompatUnknown()}}</td>
        <td>{{CompatGeckoMobile("4")}}</td>
        <td>{{CompatUnknown()}}</td>
        <td>10.60</td>
        <td>{{CompatUnknown()}}</td>
      </tr>
    </tbody>
  </table>
</div>
<h2 id="See_also">See also</h2>
<ul>
  <li><a href="/en-US/docs/WebAPI/Using_geolocation" title="/en-US/docs/WebAPI/Using_geolocation">Using geolocation</a></li>
  <li>The {{domxref("Geolocation")}} interface that uses it.</li>
</ul>
Revert to this revision