Fetching a user’s location with Elm’s geolocation package is pretty simple, but you may run into errors with Safari. Make sure you use https
, and use the nowWith
function to specify a timeout to get Safari to work properly.
Examples
Main.elm
FetchLocation ->
let
cmd =
Geolocation.nowWith
{ enableHighAccuracy = False
, timeout = Just 2000
, maximumAge = Nothing
}
|> Task.attempt LocationUpdated
in
model ! [ cmd ]
Links