Find out about where a user’s device is located. Geolocation API.
The altitude in meters relative to sea level is held in value. The accuracy field
describes how accurate value is, also in meters.
Describes the motion of the device. If the device is not moving, this will
just be Static. If the device is moving, you will see the speed in meters
per second and the degreesFromNorth in degrees.
Note: The degreesFromNorth value goes clockwise: 0° represents true
north, 90° is east, 180° is south, 270° is west, etc.
This is used to force a major version bump when the JS changes.
You'll usually not use it for anything.
Enable receipt of changes as the browser device moves.
Stop receiving changes as the browser device moves.
The now functions may fail for a variety of reasons.
* The user may reject the request to use their location.
* It may be impossible to get a location.
* If you set a timeout in the `Options` the request may just take too long.In each case, the browser will provide a string with additional information.
There are a couple options you can mess with when requesting location data.
enableHighAccuracy — When enabled, the device will attempt to provide
a more accurate location. This can result in slower response times or
increased power consumption (with a GPS chip on a mobile device for example).
When disabled, the device can take the liberty to save resources by responding
more quickly and/or using less power.timeout — Requesting a location can take time, so you have the option
to provide an upper bound in milliseconds on that wait.maximumAge — This API can return cached locations. If this is set
to Just 400 you may get cached locations as long as they were read in the
last 400 milliseconds. If this is Nothing then the device must attempt
to retrieve the current location every time.The options you will want in 99% of cases. This will get you faster results, less battery drain, no surprise failures due to timeouts, and no surprising cached results.
{ enableHighAccuracy = False
, timeout = Nothing
, maximumAge = Nothing
}Messages sent between Elm and the port JavaScript.
Opaque type, returned by now, nowWith, changes, stopChanges.
Internal module state.
Responses.
LocationResponse is returned from a now or nowWith message, and for changes if you've subscriped with a changes message.
ErrorResponse is returned if there is an error.
NoResponse is sent if the processing code receives a message that is not a valid response message. Shouldn't happen.
PortFunnel.FunnelSpecThe name of this module: "Geolocation".
Our module descriptor.
Responsible for sending a CmdResponse back througt the port.
Called by PortFunnel.appProcess for each response returned by process.
Always returns Cmd.none.
StateThe initial, empty state, so the application can initialize its state.
Message out the Cmd PortConvert a Message to the same JSON string that gets sent
over the wire to the JS code.
Make a simulated Cmd port.
Returns true if a Startup message has been processed.
This is sent by the port code after it has initialized.
Convert an Error to a string for simple printing.
All available details of the device's current location in the world.
latitude— the latitude in decimal degrees.longitude— the longitude in decimal degrees.accuracy— the accuracy of the latitude and longitude, expressed in meters.altitude— altitude information, if available.movement— information about how the device is moving, if available.timestamp— the time that this location reading was taken in milliseconds.