Calculate a route between two points
client.Routing.Route(ctx, params) (*RouteResult, error)
POST/api/v1/route
Calculate a route between two points
package main
import (
"context"
"fmt"
"github.com/plazafyi/plaza-go"
"github.com/plazafyi/plaza-go/option"
)
func main() {
client := githubcomplazafyiplazago.NewClient(
option.WithAPIKey("My API Key"),
)
routeResult, err := client.Routing.Route(context.TODO(), githubcomplazafyiplazago.RoutingRouteParams{
RouteRequest: githubcomplazafyiplazago.RouteRequestParam{
Destination: githubcomplazafyiplazago.F(githubcomplazafyiplazago.RouteRequestDestinationParam{
Lat: githubcomplazafyiplazago.F(48.858400),
Lng: githubcomplazafyiplazago.F(2.294500),
}),
Origin: githubcomplazafyiplazago.F(githubcomplazafyiplazago.RouteRequestOriginParam{
Lat: githubcomplazafyiplazago.F(48.856600),
Lng: githubcomplazafyiplazago.F(2.352200),
}),
},
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", routeResult.Geometry)
}
{
"geometry": {
"coordinates": [
2.3522,
48.8566
],
"type": "Point"
},
"properties": {
"distance_m": 4523.7,
"duration_s": 847.2,
"annotations": {
"foo": "bar"
},
"charge_profile": [
[
0
]
],
"charging_stops": [
{
"foo": "bar"
}
],
"edges": [
{
"foo": "bar"
}
],
"energy_used_wh": 0
},
"type": "Feature"
}Returns Examples
{
"geometry": {
"coordinates": [
2.3522,
48.8566
],
"type": "Point"
},
"properties": {
"distance_m": 4523.7,
"duration_s": 847.2,
"annotations": {
"foo": "bar"
},
"charge_profile": [
[
0
]
],
"charging_stops": [
{
"foo": "bar"
}
],
"edges": [
{
"foo": "bar"
}
],
"energy_used_wh": 0
},
"type": "Feature"
}