本文整理汇总了Golang中github.com/cdupuis/strava/activity-namer/Godeps/_workspace/src/googlemaps/github/io/maps.Client类的典型用法代码示例。如果您正苦于以下问题:Golang Client类的具体用法?Golang Client怎么用?Golang Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Client类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
flag.Parse()
var client *maps.Client
var err error
if *apiKey != "" {
client, err = maps.NewClient(maps.WithAPIKey(*apiKey))
} else if *clientID != "" || *signature != "" {
client, err = maps.NewClient(maps.WithClientIDAndSignature(*clientID, *signature))
} else {
usageAndExit("Please specify an API Key, or Client ID and Signature.")
}
check(err)
r := &maps.GeocodingRequest{
Address: *address,
Language: *language,
Region: *region,
}
parseComponents(*components, r)
parseBounds(*bounds, r)
parseLatLng(*latlng, r)
parseResultType(*resultType, r)
parseLocationType(*locationType, r)
resp, err := client.Geocode(context.Background(), r)
check(err)
pretty.Println(resp)
}
开发者ID:cdupuis,项目名称:strava,代码行数:31,代码来源:main.go
示例2: main
func main() {
flag.Parse()
var client *maps.Client
var err error
if *apiKey != "" {
client, err = maps.NewClient(maps.WithAPIKey(*apiKey))
} else if *clientID != "" || *signature != "" {
client, err = maps.NewClient(maps.WithClientIDAndSignature(*clientID, *signature))
} else {
usageAndExit("Please specify an API Key, or Client ID and Signature.")
}
check(err)
r := &maps.QueryAutocompleteRequest{
Input: *input,
Language: *language,
Radius: *radius,
Offset: *offset,
}
parseLocation(*location, r)
resp, err := client.QueryAutocomplete(context.Background(), r)
check(err)
pretty.Println(resp)
}
开发者ID:cdupuis,项目名称:strava,代码行数:28,代码来源:queryautocomplete.go
示例3: main
func main() {
flag.Parse()
var client *maps.Client
var err error
if *apiKey != "" {
client, err = maps.NewClient(maps.WithAPIKey(*apiKey))
} else if *clientID != "" || *signature != "" {
client, err = maps.NewClient(maps.WithClientIDAndSignature(*clientID, *signature))
} else {
usageAndExit("Please specify an API Key, or Client ID and Signature.")
}
check(err)
t, err := strconv.Atoi(*timestamp)
check(err)
r := &maps.TimezoneRequest{
Language: *language,
Timestamp: time.Unix(int64(t), 0),
}
parseLocation(*location, r)
resp, err := client.Timezone(context.Background(), r)
check(err)
pretty.Println(resp)
}
开发者ID:cdupuis,项目名称:strava,代码行数:29,代码来源:main.go
示例4: main
func main() {
flag.Parse()
var client *maps.Client
var err error
if *apiKey != "" {
client, err = maps.NewClient(maps.WithAPIKey(*apiKey))
} else if *clientID != "" || *signature != "" {
client, err = maps.NewClient(maps.WithClientIDAndSignature(*clientID, *signature))
} else {
usageAndExit("Please specify an API Key, or Client ID and Signature.")
}
check(err)
r := &maps.TextSearchRequest{
Query: *query,
Language: *language,
Radius: *radius,
OpenNow: *opennow,
}
parseLocation(*location, r)
parsePriceLevels(*minprice, *maxprice, r)
resp, err := client.TextSearch(context.Background(), r)
check(err)
pretty.Println(resp)
}
开发者ID:cdupuis,项目名称:strava,代码行数:29,代码来源:textsearch.go
示例5: main
func main() {
flag.Parse()
var client *maps.Client
var err error
if *apiKey != "" {
client, err = maps.NewClient(maps.WithAPIKey(*apiKey))
} else if *clientID != "" || *signature != "" {
client, err = maps.NewClient(maps.WithClientIDAndSignature(*clientID, *signature))
} else {
usageAndExit("Please specify an API Key, or Client ID and Signature.")
}
check(err)
r := &maps.ElevationRequest{}
if *samples > 0 {
r.Samples = *samples
}
if *locations != "" {
l, err := decodeLocations(*locations)
check(err)
r.Locations = l
}
if *path != "" {
p, err := decodePath(*path)
check(err)
r.Path = p
}
resp, err := client.Elevation(context.Background(), r)
if err != nil {
log.Fatalf("Could not request elevations: %v", err)
}
pretty.Println(resp)
}
开发者ID:cdupuis,项目名称:strava,代码行数:39,代码来源:main.go
示例6: main
func main() {
flag.Parse()
var client *maps.Client
var err error
if *apiKey != "" {
client, err = maps.NewClient(maps.WithAPIKey(*apiKey))
} else if *clientID != "" || *signature != "" {
client, err = maps.NewClient(maps.WithClientIDAndSignature(*clientID, *signature))
} else {
usageAndExit("Please specify an API Key, or Client ID and Signature.")
}
check(err)
r := &maps.PlacePhotoRequest{
PhotoReference: *photoreference,
MaxHeight: uint(*maxheight),
MaxWidth: uint(*maxwidth),
}
resp, err := client.PlacePhoto(context.Background(), r)
check(err)
log.Printf("Content-Type: %v\n", resp.ContentType)
img, err := resp.Image()
check(err)
log.Printf("Image bounds: %v", img.Bounds())
if *basename != "" {
filename := fmt.Sprintf("%s.%s", *basename, "jpg")
f, err := os.Create(filename)
check(err)
err = jpeg.Encode(f, img, &jpeg.Options{Quality: 85})
check(err)
log.Printf("Wrote image to %s\n", filename)
}
}
开发者ID:cdupuis,项目名称:strava,代码行数:38,代码来源:photo.go
示例7: main
func main() {
flag.Parse()
var client *maps.Client
var err error
if *apiKey != "" {
client, err = maps.NewClient(maps.WithAPIKey(*apiKey))
} else if *clientID != "" || *signature != "" {
client, err = maps.NewClient(maps.WithClientIDAndSignature(*clientID, *signature))
} else {
usageAndExit("Please specify an API Key, or Client ID and Signature.")
}
check(err)
r := &maps.DistanceMatrixRequest{
Language: *language,
DepartureTime: *departureTime,
ArrivalTime: *arrivalTime,
}
if *origins != "" {
r.Origins = strings.Split(*origins, "|")
}
if *destinations != "" {
r.Destinations = strings.Split(*destinations, "|")
}
lookupMode(*mode, r)
lookupAvoid(*avoid, r)
lookupUnits(*units, r)
lookupTransitMode(*transitMode, r)
lookupTransitRoutingPreference(*transitRoutingPreference, r)
resp, err := client.DistanceMatrix(context.Background(), r)
check(err)
pretty.Println(resp)
}
开发者ID:cdupuis,项目名称:strava,代码行数:38,代码来源:main.go
示例8: geocode
func geocode(mapsClient *maps.Client, lat float64, lng float64) (string, string) {
r := &maps.GeocodingRequest{
LatLng: &maps.LatLng{Lat: lat, Lng: lng},
}
resp, err := mapsClient.Geocode(context.Background(), r)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
var city, country string
for _, b := range resp[0].AddressComponents {
if stringInSlice("country", b.Types) {
country = b.LongName
}
if stringInSlice("locality", b.Types) {
city = b.LongName
}
}
return city, country
}
开发者ID:cdupuis,项目名称:strava,代码行数:23,代码来源:main.go
示例9: main
func main() {
flag.Parse()
var client *maps.Client
var err error
if *apiKey != "" {
client, err = maps.NewClient(maps.WithAPIKey(*apiKey))
} else if *clientID != "" || *signature != "" {
client, err = maps.NewClient(maps.WithClientIDAndSignature(*clientID, *signature))
} else {
usageAndExit("Please specify an API Key, or Client ID and Signature.")
}
check(err)
r := &maps.PlaceDetailsRequest{
PlaceID: *placeID,
}
resp, err := client.PlaceDetails(context.Background(), r)
check(err)
pretty.Println(resp)
}
开发者ID:cdupuis,项目名称:strava,代码行数:23,代码来源:placedetails.go
示例10: main
func main() {
flag.Parse()
var client *maps.Client
var err error
if *apiKey != "" {
client, err = maps.NewClient(maps.WithAPIKey(*apiKey), maps.WithRateLimit(2))
} else if *clientID != "" || *signature != "" {
client, err = maps.NewClient(maps.WithClientIDAndSignature(*clientID, *signature))
} else {
usageAndExit("Please specify an API Key, or Client ID and Signature.")
}
check(err)
r := &maps.DirectionsRequest{
Origin: *origin,
Destination: *destination,
DepartureTime: *departureTime,
ArrivalTime: *arrivalTime,
Alternatives: *alternatives,
Language: *language,
Region: *region,
}
lookupMode(*mode, r)
lookupUnits(*units, r)
lookupTransitRoutingPreference(*transitRoutingPreference, r)
lookupTrafficModel(*trafficModel, r)
if *waypoints != "" {
r.Waypoints = strings.Split(*waypoints, "|")
}
if *avoid != "" {
for _, a := range strings.Split(*avoid, "|") {
switch a {
case "tolls":
r.Avoid = append(r.Avoid, maps.AvoidTolls)
case "highways":
r.Avoid = append(r.Avoid, maps.AvoidHighways)
case "ferries":
r.Avoid = append(r.Avoid, maps.AvoidFerries)
default:
log.Fatalf("Unknown avoid restriction %s", a)
}
}
}
if *transitMode != "" {
for _, t := range strings.Split(*transitMode, "|") {
switch t {
case "bus":
r.TransitMode = append(r.TransitMode, maps.TransitModeBus)
case "subway":
r.TransitMode = append(r.TransitMode, maps.TransitModeSubway)
case "train":
r.TransitMode = append(r.TransitMode, maps.TransitModeTrain)
case "tram":
r.TransitMode = append(r.TransitMode, maps.TransitModeTram)
case "rail":
r.TransitMode = append(r.TransitMode, maps.TransitModeRail)
}
}
}
if *iterations == 1 {
routes, waypoints, err := client.Directions(context.Background(), r)
check(err)
pretty.Println(waypoints)
pretty.Println(routes)
} else {
done := make(chan iterationResult)
for i := 0; i < *iterations; i++ {
go func(i int) {
startTime := time.Now()
_, _, err := client.Directions(context.Background(), r)
done <- iterationResult{
fmt.Sprintf("Iteration %2d: round trip %.2f seconds", i, float64(time.Now().Sub(startTime))/1000000000),
err,
}
}(i)
}
for i := 0; i < *iterations; i++ {
result := <-done
if err != nil {
fmt.Printf("error: %+v\n", result.err)
} else {
fmt.Println(result.result)
}
}
}
}
开发者ID:cdupuis,项目名称:strava,代码行数:93,代码来源:main.go
注:本文中的github.com/cdupuis/strava/activity-namer/Godeps/_workspace/src/googlemaps/github/io/maps.Client类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论