本文整理汇总了Golang中github.com/cdupuis/strava/activity-namer/Godeps/_workspace/src/googlemaps/github/io/maps.Client.PlacePhoto方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.PlacePhoto方法的具体用法?Golang Client.PlacePhoto怎么用?Golang Client.PlacePhoto使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cdupuis/strava/activity-namer/Godeps/_workspace/src/googlemaps/github/io/maps.Client
的用法示例。
在下文中一共展示了Client.PlacePhoto方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.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)
}
}