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.RadarSearchRequest{
		Radius:  *radius,
		Keyword: *keyword,
		Name:    *name,
		OpenNow: *opennow,
	}

	parseLocation(*location, r)
	parsePriceLevels(*minprice, *maxprice, r)
	parsePlaceType(*placeType, r)

	resp, err := client.RadarSearch(context.Background(), r)
	check(err)

	for i, result := range resp.Results {
		r2 := &maps.PlaceDetailsRequest{
			PlaceID: result.PlaceID,
		}
		resp, err := client.PlaceDetails(context.Background(), r2)
		check(err)

		fmt.Printf("%d: %v at %v\n", i, resp.Name, resp.FormattedAddress)
	}
}
Esempio n. 2
0
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)
}