-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Bindings to the Google Geocoding API (formerly Maps -- Geocoding API) -- -- The Google Geocoding API provides a direct way to access -- geocoding and reverse geocoding services via an HTTP request. This -- library package provides bindings in Haskell to that API. -- -- NB: The use of the API's services is subject to the Google Maps -- Platform Terms of Service, which terms restrict the use of -- content. End Users’ use of Google Maps is subject to the then-current -- Google Maps/Google Earth Additional Terms of Service at -- https://maps.google.com/help/terms_maps.html and Google Privacy -- Policy at https://www.google.com/policies/privacy/. -- -- This package has no connection with Google Inc. or its affiliates. @package google-maps-geocoding @version 0.7.0.1 -- | This package has no connection with Google Inc. or its affiliates. -- -- The Google Geocoding API provides a direct way to access -- geocoding and reverse geocoding services via an HTTP request. This -- library provides bindings in Haskell to that API. -- -- NB: The use of the Google Geocoding API services is subject to the -- Google Maps Platform Terms of Service, which terms restrict the -- use of content. End Users’ use of Google Maps is subject to the -- then-current Google Maps/Google Earth Additional Terms of Service at -- https://maps.google.com/help/terms_maps.html and Google Privacy -- Policy at https://www.google.com/policies/privacy/. -- -- The code below is an example console application to test privately the -- use of the library with the Google Geocoding API. -- --
-- {-# LANGUAGE OverloadedStrings #-}
--
-- module Main (main) where
--
-- import Data.Maybe (fromJust)
-- import Data.Text (Text)
-- import Data.Text.IO as T (getLine, putStr)
-- import Graphics.Gloss (Display (..), display, white)
-- import Graphics.Gloss.Juicy (fromDynamicImage)
-- import Network.HTTP.Client (Manager, newManager)
-- import Network.HTTP.Client.TLS (tlsManagerSettings)
-- import Web.Google.Geocoding (Address (..), geocode, GeocodingResponse (..),
-- Geometry (..), Key (..), LatLng (..), Result (..), Status (..))
-- import Web.Google.Maps.Static (Center (..), Location (..), Size (..),
-- staticmap, Zoom (..))
-- import System.IO (hFlush, stdout)
--
-- main :: IO ()
-- main = do
-- putStrLn $ "A test of the Google Geocoding API.\nNB: The use of " ++
-- "the API services is subject to the Google Maps Platform Terms of " ++
-- "Serivce at https://cloud.google.com/maps-platform/terms/.\n"
-- txt <- input "Enter full address: "
-- mgr <- newManager tlsManagerSettings
-- let apiKey = Key "<REPLACE_THIS_WITH_YOUR_ACTUAL_GOOGLE_API_KEY>"
-- result <- geocode mgr apiKey (Just $ Address txt) Nothing Nothing
-- Nothing Nothing
-- case result of
-- Right response -> do
-- let s = status response
-- case s of
-- OK -> do
-- let latlng = location $ geometry $ head $ results response
-- center = Center $ Coord latlng
-- print center
-- displayMap mgr apiKey center
-- _ -> putStrLn $ "Error! Status: " ++ show s
-- _ -> putStrLn $ "Error! Result:\n" ++ show result
--
-- input :: Text -> IO Text
-- input msg = T.putStr msg >> hFlush stdout >> T.getLine
--
-- displayMap :: Manager -> Key -> Center -> IO ()
-- displayMap mgr apiKey center = do
-- let zoom = Just $ Zoom 17
-- w = 400
-- h = 400
-- size = Size w h
-- result <- staticmap mgr apiKey Nothing (Just center) zoom size Nothing
-- Nothing [] Nothing [] [] Nothing
-- case result of
-- Right response -> do
-- let picture = fromJust $ fromDynamicImage response
-- title = "Test Google Geocoding API"
-- window = InWindow title (w, h) (10, 10)
-- display window white picture
-- Left err -> putStrLn $ "Error while displaying map: " ++ show err
--
module Web.Google.Geocoding
-- | Geocode. NB: The use of the Google Geocoding API services is subject
-- to the Google Maps Platform Terms of Service. End Users’ use of
-- Google Maps is subject to the then-current Google Maps/Google Earth
-- Additional Terms of Service at
-- https://maps.google.com/help/terms_maps.html and Google Privacy
-- Policy at https://www.google.com/policies/privacy/.
geocode :: Manager -> Key -> Maybe Address -> Maybe [FilterComponent] -> Maybe Viewport -> Maybe Language -> Maybe Region -> IO (Either ClientError GeocodingResponse)
-- | Reverse (back) geocode. NB: The use of the Google Geocoding API
-- services is subject to the Google Maps Platform Terms of
-- Service. End Users’ use of Google Maps is subject to the
-- then-current Google Maps/Google Earth Additional Terms of Service at
-- https://maps.google.com/help/terms_maps.html and Google Privacy
-- Policy at https://www.google.com/policies/privacy/.
backGeocode :: Manager -> Key -> Maybe LatLng -> Maybe PlaceId -> Maybe AddressType -> Maybe LocationType -> Maybe Language -> IO (Either ClientError GeocodingResponse)
-- | Google Geocoding API
type GoogleGeocodingAPI = "geocode" :> "json" :> QueryParam "key" Key :> QueryParam "address" Address :> QueryParam "components" [FilterComponent] :> QueryParam "bounds" Viewport :> QueryParam "language" Language :> QueryParam "region" Region :> Get '[JSON] GeocodingResponse :<|> "geocode" :> "json" :> QueryParam "key" Key :> QueryParam "latlng" LatLng :> QueryParam "place_id" PlaceId :> QueryParam "result_type" AddressType :> QueryParam "location_type" LocationType :> QueryParam "language" Language :> Get '[JSON] GeocodingResponse
-- | API type
api :: Proxy GoogleGeocodingAPI
-- | API key
newtype Key
Key :: Text -> Key
-- | Address
newtype Address
Address :: Text -> Address
-- | Fliter component: a component that can be used to filter the results
-- returned in a geocoding response.
data FilterComponent
Route :: Text -> FilterComponent
Locality :: Text -> FilterComponent
AdministrativeArea :: Text -> FilterComponent
PostalCode :: Text -> FilterComponent
Country :: Region -> FilterComponent
-- | Viewport
data Viewport
Viewport :: LatLng -> LatLng -> Viewport
[southwest] :: Viewport -> LatLng
[northeast] :: Viewport -> LatLng
-- | Language: supported languages based on the list at
-- https://developers.google.com/maps/faq#languagesupport (as at
-- 20 March 2022).
data Language
Afrikaans :: Language
Albanian :: Language
Amharic :: Language
Arabic :: Language
Armenian :: Language
Azerbaijani :: Language
Basque :: Language
Belarusian :: Language
Bengali :: Language
Bosnian :: Language
Bulgarian :: Language
Burmese :: Language
Catalan :: Language
Chinese :: Language
ChineseSimplified :: Language
ChineseHongKong :: Language
ChineseTraditional :: Language
Croatian :: Language
Czech :: Language
Danish :: Language
Dutch :: Language
English :: Language
EnglishAustralian :: Language
EnglishBritish :: Language
Estonian :: Language
Farsi :: Language
Filipino :: Language
Finnish :: Language
French :: Language
FrenchCanadian :: Language
Galician :: Language
Georgian :: Language
German :: Language
Greek :: Language
Gujarati :: Language
Hebrew :: Language
Hindi :: Language
Icelandic :: Language
Hungarian :: Language
Indonesian :: Language
Italian :: Language
Japanese :: Language
Kannada :: Language
Kazakh :: Language
Khmer :: Language
Korean :: Language
Kyrgyz :: Language
Lao :: Language
Latvian :: Language
Lithuanian :: Language
Macedonian :: Language
Malay :: Language
Malayalam :: Language
Marathi :: Language
Mongolian :: Language
Nepali :: Language
Norwegian :: Language
Polish :: Language
Portuguese :: Language
PortugueseBrazil :: Language
PortuguesePortugal :: Language
Punjabi :: Language
Romanian :: Language
Russian :: Language
Serbian :: Language
Sinhalese :: Language
Slovak :: Language
Slovenian :: Language
Spanish :: Language
SpanishLatinAmerican :: Language
Swahili :: Language
Swedish :: Language
-- | No longer listed by Google at 12 June 2021. See Filipino.
Tagalog :: Language
Tamil :: Language
Telugu :: Language
Thai :: Language
Turkish :: Language
Ukrainian :: Language
Urdu :: Language
Uzbek :: Language
Vietnamese :: Language
Zulu :: Language
-- | Region: a ccTLD (country code top level domain).
data Region
AD :: Region
AE :: Region
AF :: Region
AG :: Region
AI :: Region
AL :: Region
AM :: Region
AO :: Region
AQ :: Region
AR :: Region
AS :: Region
AT :: Region
AU :: Region
AW :: Region
AX :: Region
AZ :: Region
BA :: Region
BB :: Region
BD :: Region
BE :: Region
BF :: Region
BG :: Region
BH :: Region
BI :: Region
BJ :: Region
BL :: Region
BM :: Region
BN :: Region
BO :: Region
BQ :: Region
BR :: Region
BS :: Region
BT :: Region
BV :: Region
BW :: Region
BY :: Region
BZ :: Region
CA :: Region
CC :: Region
CD :: Region
CF :: Region
CG :: Region
CH :: Region
CI :: Region
CK :: Region
CL :: Region
CM :: Region
CN :: Region
CO :: Region
CR :: Region
CU :: Region
CV :: Region
CW :: Region
CX :: Region
CY :: Region
CZ :: Region
DE :: Region
DJ :: Region
DK :: Region
DM :: Region
DO :: Region
DZ :: Region
EC :: Region
EE :: Region
EG :: Region
EH :: Region
ER :: Region
ES :: Region
ET :: Region
FI :: Region
FJ :: Region
FK :: Region
FM :: Region
FO :: Region
FR :: Region
GA :: Region
GB :: Region
GD :: Region
GE :: Region
GF :: Region
GG :: Region
GH :: Region
GI :: Region
GL :: Region
GM :: Region
GN :: Region
GP :: Region
GQ :: Region
GR :: Region
GS :: Region
GT :: Region
GU :: Region
GW :: Region
GY :: Region
HK :: Region
HM :: Region
HN :: Region
HR :: Region
HT :: Region
HU :: Region
ID :: Region
IE :: Region
IL :: Region
IM :: Region
IN :: Region
IO :: Region
IQ :: Region
IR :: Region
IS :: Region
IT :: Region
JE :: Region
JM :: Region
JO :: Region
JP :: Region
KE :: Region
KG :: Region
KH :: Region
KI :: Region
KM :: Region
KN :: Region
KP :: Region
KR :: Region
KW :: Region
KY :: Region
KZ :: Region
LA :: Region
LB :: Region
LC :: Region
LI :: Region
LK :: Region
LR :: Region
LS :: Region
LT :: Region
LU :: Region
LV :: Region
LY :: Region
MA :: Region
MC :: Region
MD :: Region
ME :: Region
MF :: Region
MG :: Region
MH :: Region
MK :: Region
ML :: Region
MM :: Region
MN :: Region
MO :: Region
MP :: Region
MQ :: Region
MR :: Region
MS :: Region
MT :: Region
MU :: Region
MV :: Region
MW :: Region
MX :: Region
MY :: Region
MZ :: Region
NA :: Region
NC :: Region
NE :: Region
NF :: Region
NG :: Region
NI :: Region
NL :: Region
NO :: Region
NP :: Region
NR :: Region
NU :: Region
NZ :: Region
OM :: Region
PA :: Region
PE :: Region
PF :: Region
PG :: Region
PH :: Region
PK :: Region
PL :: Region
PM :: Region
PN :: Region
PR :: Region
PS :: Region
PT :: Region
PW :: Region
PY :: Region
QA :: Region
RE :: Region
RO :: Region
RS :: Region
RU :: Region
RW :: Region
SA :: Region
SB :: Region
SC :: Region
SD :: Region
SE :: Region
SG :: Region
SH :: Region
SI :: Region
SJ :: Region
SK :: Region
SL :: Region
SM :: Region
SN :: Region
SO :: Region
SR :: Region
SS :: Region
ST :: Region
SV :: Region
SX :: Region
SY :: Region
SZ :: Region
TC :: Region
TD :: Region
TF :: Region
TG :: Region
TH :: Region
TJ :: Region
TK :: Region
TL :: Region
TM :: Region
TN :: Region
TO :: Region
TR :: Region
TT :: Region
TV :: Region
TW :: Region
TZ :: Region
UA :: Region
UG :: Region
UM :: Region
US :: Region
UY :: Region
UZ :: Region
VA :: Region
VC :: Region
VE :: Region
VG :: Region
VI :: Region
VN :: Region
VU :: Region
WF :: Region
WS :: Region
YE :: Region
YT :: Region
ZA :: Region
ZM :: Region
ZW :: Region
AC :: Region
UK :: Region
EU :: Region
-- | Geocoding Reponse
data GeocodingResponse
GeocodingResponse :: Status -> Maybe Text -> [Result] -> GeocodingResponse
[status] :: GeocodingResponse -> Status
[error_message] :: GeocodingResponse -> Maybe Text
[results] :: GeocodingResponse -> [Result]
-- | Contains the status of the request and may contain debugging
-- information to help you track down why geocoding is not working.
data Status
-- | Indicates that no errors occurred; the address was successfully parsed
-- and at least one geocode was returned.
OK :: Status
-- | Indicates that the geocode was successful but returned no results.
-- This may occur if the geocoder was passed a non-existent address.
ZeroResults :: Status
OverQueryLimit :: Status
RequestDenied :: Status
-- | Generally indicates that the query (address, components or latlng) is
-- missing.
InvalidRequest :: Status
UnknownError :: Status
-- | A result of the geocoder.
data Result
Result :: [AddressType] -> Text -> [AddressComponent] -> Maybe [PostcodeLocality] -> Geometry -> Maybe Bool -> PlaceId -> Result
[types] :: Result -> [AddressType]
[formatted_address] :: Result -> Text
[address_components] :: Result -> [AddressComponent]
[postcode_localities] :: Result -> Maybe [PostcodeLocality]
[geometry] :: Result -> Geometry
[partial_match] :: Result -> Maybe Bool
[place_id] :: Result -> PlaceId
-- | Address (and address component) type: The list of types provided by
-- Google (as at 4 March 2017) is incomplete.
newtype AddressType
AddressType :: Text -> AddressType
-- | Address component
data AddressComponent
AddressComponent :: [AddressType] -> Text -> Text -> AddressComponent
[address_component_types] :: AddressComponent -> [AddressType]
[long_name] :: AddressComponent -> Text
[short_name] :: AddressComponent -> Text
-- | Postcode locality: a locality contained in a postal code.
newtype PostcodeLocality
PostcodeLocality :: Text -> PostcodeLocality
-- | Geometry
data Geometry
Geometry :: LatLng -> LocationType -> Viewport -> Maybe Viewport -> Geometry
[location] :: Geometry -> LatLng
[location_type] :: Geometry -> LocationType
[viewport] :: Geometry -> Viewport
[bounds] :: Geometry -> Maybe Viewport
-- | Latitude and longitude: precision beyond 6 decimal places is ignored.
data LatLng
LatLng :: Double -> Double -> LatLng
-- | Takes any value between -90 and 90.
[lat] :: LatLng -> Double
-- | Takes any value between -180 and 180.
[lng] :: LatLng -> Double
-- | Place id
newtype PlaceId
PlaceId :: Text -> PlaceId
-- | Location
data Location
Coords :: LatLng -> Location
Locale :: Address -> Location
-- | Location type
data LocationType
Rooftop :: LocationType
RangeInterpolated :: LocationType
GeometricCenter :: LocationType
Approximate :: LocationType
instance GHC.Show.Show Web.Google.Geocoding.FilterComponent
instance GHC.Classes.Eq Web.Google.Geocoding.FilterComponent
instance GHC.Show.Show Web.Google.Geocoding.Status
instance GHC.Classes.Eq Web.Google.Geocoding.Status
instance Web.Internal.HttpApiData.ToHttpApiData Web.Google.Geocoding.AddressType
instance GHC.Generics.Generic Web.Google.Geocoding.AddressType
instance GHC.Show.Show Web.Google.Geocoding.AddressType
instance GHC.Classes.Eq Web.Google.Geocoding.AddressType
instance GHC.Generics.Generic Web.Google.Geocoding.AddressComponent
instance GHC.Show.Show Web.Google.Geocoding.AddressComponent
instance GHC.Classes.Eq Web.Google.Geocoding.AddressComponent
instance GHC.Generics.Generic Web.Google.Geocoding.PostcodeLocality
instance GHC.Show.Show Web.Google.Geocoding.PostcodeLocality
instance GHC.Classes.Eq Web.Google.Geocoding.PostcodeLocality
instance GHC.Show.Show Web.Google.Geocoding.LocationType
instance GHC.Classes.Eq Web.Google.Geocoding.LocationType
instance GHC.Generics.Generic Web.Google.Geocoding.Viewport
instance GHC.Show.Show Web.Google.Geocoding.Viewport
instance GHC.Classes.Eq Web.Google.Geocoding.Viewport
instance GHC.Generics.Generic Web.Google.Geocoding.Geometry
instance GHC.Show.Show Web.Google.Geocoding.Geometry
instance GHC.Classes.Eq Web.Google.Geocoding.Geometry
instance Web.Internal.HttpApiData.ToHttpApiData Web.Google.Geocoding.PlaceId
instance GHC.Generics.Generic Web.Google.Geocoding.PlaceId
instance GHC.Show.Show Web.Google.Geocoding.PlaceId
instance GHC.Classes.Eq Web.Google.Geocoding.PlaceId
instance GHC.Generics.Generic Web.Google.Geocoding.Result
instance GHC.Show.Show Web.Google.Geocoding.Result
instance GHC.Classes.Eq Web.Google.Geocoding.Result
instance GHC.Generics.Generic Web.Google.Geocoding.GeocodingResponse
instance GHC.Show.Show Web.Google.Geocoding.GeocodingResponse
instance GHC.Classes.Eq Web.Google.Geocoding.GeocodingResponse
instance Data.Aeson.Types.FromJSON.FromJSON Web.Google.Geocoding.GeocodingResponse
instance Data.Aeson.Types.FromJSON.FromJSON Web.Google.Geocoding.Result
instance Data.Aeson.Types.FromJSON.FromJSON Web.Google.Geocoding.PlaceId
instance Data.Aeson.Types.FromJSON.FromJSON Web.Google.Geocoding.Geometry
instance Web.Internal.HttpApiData.ToHttpApiData Web.Google.Geocoding.Viewport
instance Data.Aeson.Types.FromJSON.FromJSON Web.Google.Geocoding.Viewport
instance Web.Internal.HttpApiData.ToHttpApiData Web.Google.Geocoding.LocationType
instance Data.Aeson.Types.FromJSON.FromJSON Web.Google.Geocoding.LocationType
instance Data.Aeson.Types.FromJSON.FromJSON Web.Google.Geocoding.PostcodeLocality
instance Data.Aeson.Types.FromJSON.FromJSON Web.Google.Geocoding.AddressComponent
instance Data.Aeson.Types.FromJSON.FromJSON Web.Google.Geocoding.AddressType
instance Data.Aeson.Types.FromJSON.FromJSON Web.Google.Geocoding.Status
instance Web.Internal.HttpApiData.ToHttpApiData Web.Google.Geocoding.FilterComponent
instance Web.Internal.HttpApiData.ToHttpApiData [Web.Google.Geocoding.FilterComponent]