Expand description
The most simplest of location mechanism that uses the native browser to
fetch location info about current device. This module provides __location__,
a versatile function that works with both sync and async contexts.
The browser will prompt the user for location permission upon acceptance, the location data will be returned back.
- Binds a temporary HTTP server on a random
localhostport using thesocket-servermodule. - Opens the system’s default browser to a consent page served by that
server (using the
webbrowsercrate — works on macOS, Windows, and Linux). - The browser prompts the user for location permission via the standard
navigator.geolocation.getCurrentPositionWeb API. - On success the browser POSTs the coordinates back to the local server, which shuts itself down and returns the data to the caller.
Structs§
- Location
Data - Geographic coordinates returned by the browser Geolocation API.
Enums§
- Location
Error - Errors that can be returned by
__location__. - Page
Template - Controls what the user sees in the browser when
__location__is called.
Functions§
- __
location__ - Capture the user’s geographic location by opening the browser to a local consent page.
- __
location_ async__ - Async version of
__location__.
Attribute Macros§
- browser
- Concise attribute macro alternative to calling
__location__/__location_async__directly.