本文整理匯總了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)
}
}