Request high accuracy

The options object lets you balance accuracy, waiting time, and battery use. Higher accuracy can take longer and use more power.

What you will learn

const options = {
  enableHighAccuracy: true,
  timeout: 5000,
  maximumAge: 0
};

navigator.geolocation.getCurrentPosition(
  position => console.log(position.coords),
  error => console.warn(error.code, error.message),
  options
);

Use high accuracy only when the feature needs it. A map that shows a broad area may work better with a faster, less precise result.