Modern web applications frequently incorporate location-aware functionality, adapting currency symbols, delivery estimates, regional store directories, and map views based on the user’s geographic coordinates via the W3C Geolocation API. When building and testing responsive websites on macOS, physically travelling to different cities or relying on virtual private network (VPN) server routing to test geo-dependent features is impractical. Safari on Mac includes built-in sensor emulation tools within Web Inspector that allow developers and QA engineers to override, spoof, and simulate exact latitude and longitude coordinates instantaneously.
Enabling the Develop Menu in Safari on Mac
Sensor emulation features reside within Safari’s developer toolset. If you have not previously enabled developer capabilities in Safari:
- Launch Safari on your Mac.
- Click Safari in the macOS menu bar and choose Settings (or press Cmd + ,).
- Navigate to the Advanced tab on the far right.
- Check the box labelled Show features for web developers (or "Show Develop menu in menu bar" in earlier macOS releases).
- Close the Settings window. A new Develop item appears in the top menu bar.
Opening Web Inspector and Accessing Device Settings
Once developer features are enabled, navigate to the target web application you wish to test, then launch the inspection panel:
- Right-click anywhere on the webpage and select Inspect Element (or press Option + Cmd + I).
- Within the Web Inspector toolbar at the top of the developer panel, click the Show Device Settings icon (represented by overlapping phone and tablet silhouettes, or accessible via the Console drawer).
- Alternatively, click the Settings gear icon within the Web Inspector and navigate to the Overrides or Device Emulation tab.
Overriding Geolocation Coordinates with Custom Latitude and Longitude
Inside the Device Settings emulation toolbar at the top of the viewport:
- Locate the Geolocation section.
- Change the selection from Regular (system physical GPS/Wi-Fi positioning) to Custom.
- Enter your desired decimal coordinates:
- Latitude: Enter the target decimal latitude (for example,
51.5074for London, UK). - Longitude: Enter the target decimal longitude (for example,
-0.1278). - Altitude: Optionally define altitude above sea level in metres.
- Accuracy: Define the simulated accuracy radius (such as
10metres).
- Latitude: Enter the target decimal latitude (for example,
- Press Return to apply the simulated sensor state.
Simulating Geolocation Permission Denials and Sensor Errors
Robust web applications must handle edge cases where users decline browser location access or when hardware GPS chips fail to acquire satellite lock. Web Inspector allows you to test error fallbacks without resetting global macOS privacy databases:
- Simulating Position Unavailable: Select Position Unavailable from the Geolocation drop-down menu. When the web application executes
navigator.geolocation.getCurrentPosition(), Safari immediately returns error code 2 (POSITION_UNAVAILABLE), allowing you to verify that the website displays a graceful fallback interface. - Testing Permission Prompt Handlers: Use Safari’s per-site settings (accessible via Safari > Settings for This Website) to toggle location permissions between Ask, Allow, and Deny to verify onboarding modals.
Resetting Simulated Coordinates to System Default
Once you finish debugging regional pricing algorithms or map routing pins, reset Safari’s simulated environment:
- Return to the Device Settings toolbar within Web Inspector.
- Switch the Geolocation dropdown back to Do not override (or Regular).
- Close Web Inspector. Safari immediately resumes reporting your Mac’s genuine location data as governed by macOS Location Services.