No Login Data Private Local Save

Geolocation API Simulator - Online Test Coordinates

14
0
0
0

Geolocation API Simulator

Simulate browser geolocation responses — test getCurrentPosition & watchPosition with custom coordinates, errors, and real-time tracking.

Coordinate Settings

Leave blank to set as null (unavailable).

Preset Locations
Simulation Mode
Watch Position Config

Simulates device movement. Random drift mimics real GPS jitter (~1-5m per tick).

Status: Ready — configure and simulate
Response Output
—
// Click "Simulate getCurrentPosition" or "Call Real API" to see the response here.
Accuracy Visualizer
N
40.7128, -74.0060

The dashed ring represents accuracy radius (not to scale).

watchPosition Log

No watchPosition events yet. Start tracking to see log entries.

Frequently Asked Questions

The Geolocation API is a built-in browser interface that allows web applications to access the user's geographical location (with their permission). It provides two main methods: getCurrentPosition() for a one-time location fetch, and watchPosition() for continuous tracking. The API returns a GeolocationPosition object containing coordinates, accuracy, altitude, heading, speed, and a timestamp.

getCurrentPosition() fires once and returns the current location. watchPosition() registers a callback that fires every time the device position changes, returning a unique watch ID. Use clearWatch(id) to stop tracking. watchPosition is ideal for turn-by-turn navigation, fitness trackers, or any real-time location-based app.

There are three error codes:
Code 1 — PERMISSION_DENIED: The user denied the geolocation request (or the browser blocked it).
Code 2 — POSITION_UNAVAILABLE: Location information is unavailable (e.g., no GPS signal, hardware failure).
Code 3 — TIMEOUT: The request timed out before acquiring a location fix. The timeout threshold is set via the PositionOptions.timeout property.

The accuracy value (in meters) represents the radius of a confidence interval around the reported position. For example, an accuracy of 15m means the true position is likely within a 15-meter circle around the reported coordinates. Lower numbers indicate higher precision. GPS typically offers 5-30m accuracy, while Wi-Fi triangulation may be 20-200m, and cell tower triangulation can be 100m-5km.

Yes. Since Chrome 50+, all major browsers require a secure context (HTTPS) to access the Geolocation API. This protects user privacy by preventing man-in-the-middle attacks from intercepting location data. During local development, localhost is considered a secure context and the API will work without HTTPS.

Use this Geolocation API Simulator! Set custom coordinates, accuracy, and simulate various error scenarios. You can also use Chrome DevTools: open the Sensors panel (More Tools → Sensors), select a preset location or enter custom coordinates, and the browser will override its real geolocation. BrowserStack and physical device testing are recommended for production validation.
Key Concepts
GeolocationPosition GeolocationPositionError Coordinates.latitude Coordinates.longitude Coordinates.accuracy PositionOptions enableHighAccuracy timeout maximumAge WGS84 datum navigator.geolocation