-
Notifications
You must be signed in to change notification settings - Fork 4
/
doc.go
64 lines (52 loc) · 1.5 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
Package mapquest enables access to the Open MapQuest APIs.
For further details, see http://open.mapquestapi.com/.
To get started, you need to create a client:
client := mapquest.NewClient("<your-app-key>")
// To use HTTPS, use:
client.SetHTTPS(true)
// To use your own http.Client:
client.SetHTTPClient(myClient)
// To log request and response, set a logger:
logger := log.New(os.Stderr, "", 0)
client.SetLogger(logger)
Now that you have a client, you can use the APIs.
Here's an example of how to use the MapQuest static map API:
req := &mapquest.StaticMapRequest{
Center: &mapquest.GeoPoint{
Longitude: 11.54165,
Latitude: 48.151313,
},
Zoom: 9,
Width: 500,
Height: 300,
Format: "png",
}
img, err := client.StaticMap().Get(req)
if err != nil {
panic(err)
}
To use the Geocoding API, issue a request like this:
req := &mapquest.GeocodingAddressRequest{
Location: &mapquest.GeocodingLocation{
Street: "1090 N Charlotte St",
City: "Lancaster",
State: "PA",
PostalCode: "17603",
},
}
res, err := client.Geocoding().Address(req)
if err != nil {
panic(err)
}
The Nominatim API can be used as follows:
req := &mapquest.NominatimSearchRequest{
Query: "Unter den Linden 117, Berlin, DE",
Limit: 1,
}
res, err := client.Nominatim().Search(req)
if err != nil {
panic(err)
}
*/
package mapquest