本文整理匯總了Golang中github.com/cdupuis/strava/activity-namer/Godeps/_workspace/src/googlemaps/github/io/maps.Client.DistanceMatrix方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.DistanceMatrix方法的具體用法?Golang Client.DistanceMatrix怎麽用?Golang Client.DistanceMatrix使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cdupuis/strava/activity-namer/Godeps/_workspace/src/googlemaps/github/io/maps.Client
的用法示例。
在下文中一共展示了Client.DistanceMatrix方法的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.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)
}