mapbox

package module
v0.0.0-...-4e12e38 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 11 Imported by: 0

README

go-mapbox

API Wrapper for Mapbox API

Usage

Initialization
mapboxClient, err := mapbox.NewClient(&MapboxConfig{
    Timeout: 30 * time.Second,
    APIKey:  "YOUR_API_KEY_HERE",
})
// error checking ...  
Retrieve a Matrix
request := &mapbox.DirectionsMatrixRequest{
    Profile:       mapbox.ProfileDrivingTraffic,
    Coordinates:   mapbox.Coordinates{
        mapbox.Coordinate{Lat: 33.122508, Lng: -117.306786},
        mapbox.Coordinate{Lat: 32.733810, Lng: -117.193443},
        mapbox.Coordinate{Lat: 33.676084, Lng: -117.867598},
    },

    // optional fields below
    Annotations: mapbox.Annotations{mapbox.AnnotationDistance, mapbox.AnnotationDuration},
    Approaches: mapbox.Approaches{mapbox.ApproachUnrestricted},
    Sources: mapbox.Sources{0},
    FallbackSpeed: 60,
    DepartureTime: mapbox.DepartureTime(time.Now()),
}

response, err := mapboxClient.DirectionsMatrix(context.TODO(), request)
// error checking ... 
Forward Geocode
request := &mapbox.ForwardGeocodeRequest{
    SearchText:   "6005 Hidden Valley Rd, Suite 280, Carlsbad, CA 92011"

    // optional fields below
    Autocomplete: false,
    BBox: mapbox.BoundingBox{
        Min: mapbox.Coordinate{
            Lat: 33.121217,
            Lng: -117.310429,
        }, Max: mapbox.Coordinate{
            Lat: 33.124973,
            Lng: -117.305054,
        }},
    Country:    "us",
    Language:   "en",
    Limit:      1,
    Proximity:    Coordinate{Lat: 33.121217, Lng: -117.310429,},
    Types:        mapbox.Types{mapbox.TypeCountry},
}

response, err := mapboxClient.ForwardGeocode(context.TODO(), request)
// error checking ... 
Reverse Geocode
request := &mapbox.ReverseGeocodeRequest{
    Coordinates:   mapbox.Coordinates{
        mapbox.Coordinate{Lat: 33.122508, Lng: -117.306786}
    },

    // optional fields below
    Country:     "us",
    Language:    "en",
    Limit:       1,
    Types:       mapbox.Types{mapbox.TypeCountry, mapbox.TypeAddress},
}

response, err := mapboxClient.ReverseGeocode(context.TODO(), request)
// error checking ... 
Reverse Geocode Batch
requests := ReverseGeocodeBatchRequest{
    mapbox.ReverseGeocodeRequest{
        Coordinates:   mapbox.Coordinates{
            mapbox.Coordinate{Lat: 33.122508, Lng: -117.306786}
        },
        Types:       mapbox.Types{mapbox.TypeCountry, mapbox.TypeAddress},
        Language:   "en",
    },
     mapbox.ReverseGeocodeRequest{
        Coordinates:   mapbox.Coordinates{
            mapbox.Coordinate{Lat: 32.733810, Lng: -117.193443}
        },
        Types:       mapbox.Types{mapbox.TypeCountry, mapbox.TypeAddress},
        Language:   "en",
    },
}

responses, err := mapboxClient.ReverseGeocodeBatch(context.TODO(), request)
if err != nil {
    // handle error... 
}

for i, response := range responses.Batch {
    // responses are in request order, i.e. request[i] ==> responses.Batch[i]
}
request := &mapbox.ReverseGeocodeRequest{
    Coordinates:   mapbox.Coordinates{
        mapbox.Coordinate{Lat: 33.122508, Lng: -117.306786}
    },

    // optional fields below
    Country:     "us",
    Language:    "en",
    Limit:       1,
    Types:       mapbox.Types{mapbox.TypePOI},
}

response, err := mapboxClient.SearchboxReverse(context.TODO(), request)
// error checking ... 
Retrieve Directions
request := &mapbox.DirectionsRequest{
    Profile:       mapbox.ProfileDrivingTraffic,
    Coordinates:   mapbox.Coordinates{
        mapbox.Coordinate{Lat: 33.122508, Lng: -117.306786},
        mapbox.Coordinate{Lat: 32.733810, Lng: -117.193443},
    },

    // optional fields below
    Annotations: mapbox.Annotations{mapbox.AnnotationDistance, mapbox.AnnotationDuration},
}

response, err := mapboxClient.Directions(context.TODO(), request)
// error checking ...

Documentation

Index

Constants

View Source
const (
	GeocodingRateLimit  = "geocoding"
	MatrixRateLimit     = "matrix"
	DirectionsRateLimit = "directions"
	SearchboxRateLimit  = "searchbox"
)
View Source
const (
	GeometryLngIdx = 0
	GeometryLatIdx = 1
)
View Source
const (
	GeocodingBatchEndpoint   = "/search/geocode/v6/batch"
	GeocodingReverseEndpoint = "/search/geocode/v6/reverse"
	GeocodingForwardEndpoint = "/search/geocode/v6/forward"
)
View Source
const (
	MatchCodeConfidenceExact  MatchCodeConfidence = "exact"
	MatchCodeConfidenceHigh   MatchCodeConfidence = "high"
	MatchCodeConfidenceMedium MatchCodeConfidence = "medium"
	MatchCodeConfidenceLow    MatchCodeConfidence = "low"

	MatchCodeValueMatched       MatchCodeValue = "matched"
	MatchCodeValueUnmatched     MatchCodeValue = "unmatched"
	MatchCodeValueNotApplicable MatchCodeValue = "not_applicable"
	MatchCodeValueInferred      MatchCodeValue = "inferred"
	MatchCodeValuePlausible     MatchCodeValue = "plausible"
)
View Source
const (
	ProfileDriving        = Profile("mapbox/driving")
	ProfileWalking        = Profile("mapbox/walking")
	ProfileCycling        = Profile("mapbox/cycling")
	ProfileDrivingTraffic = Profile("mapbox/driving-traffic")

	AnnotationDuration   = Annotation("duration")
	AnnotationDistance   = Annotation("distance")
	AnnotationSpeed      = Annotation("speed")
	AnnotationCongestion = Annotation("congestion")

	ApproachUnrestricted = Approach("unrestricted")
	ApproachCurb         = Approach("curb")

	TypeCountry          = Type("country")
	TypeRegion           = Type("region")
	TypePostcode         = Type("postcode")
	TypeDistrict         = Type("district")
	TypePlace            = Type("place")
	TypeLocality         = Type("locality")
	TypeNeighborhood     = Type("neighborhood")
	TypeStreet           = Type("street")
	TypeBlock            = Type("block")
	TypeAddress          = Type("address")
	TypeSecondaryAddress = Type("secondary_address")
	TypePOI              = Type("poi")
	TypePOILandmark      = Type("poi.landmark")

	ExcludeMotorway      = Exclude("motorway")
	ExcludeToll          = Exclude("toll")
	ExcludeFerry         = Exclude("ferry")
	ExcludeUnpaved       = Exclude("unpaved")
	ExcludeCashOnlyTolls = Exclude("cash_only_tolls")

	GeometriesGeoJSON   = Geometries("geojson")
	GeometriesPolyline  = Geometries("polyline")
	GeometriesPolyline6 = Geometries("polyline6")

	IncludeHov2 = Include("hov2")
	IncludeHov3 = Include("hov3")
	IncludeHot  = Include("hot")

	OverviewFull       = Overview("full")
	OverviewSimplified = Overview("simplified")
	OverviewFalse      = Overview("false")

	VoiceUnitsImpreial = VoiceUnits("imperial")
	VoiceUnitsMetric   = VoiceUnits("metric")
)
View Source
const (
	ArriveByFormat = "2006-01-02T15:04:05Z"
)
View Source
const (
	DepartAtFormat = "2006-01-02T15:04:05Z"
)
View Source
const (
	DepartureTimeFormat = "2006-01-02T15:04:05Z"
)
View Source
const (
	ResponseOK = "Ok"
)
View Source
const (
	SearchboxReverseEndpoint = "/search/searchbox/v1/reverse"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Admin

type Admin struct {
	ISO_3166_1_alpha3 string `json:"iso_3166_1_alpha3"` // The ISO 3166-1 alpha-3 country code.
	ISO_3166_1        string `json:"iso_3166_1"`        // The ISO 3166-1 alpha-2 country code.
}

Admin represents administrative region information.

type Annotation

type Annotation string

type Annotations

type Annotations []Annotation

type Approach

type Approach string

type Approaches

type Approaches []Approach

type ArriveBy

type ArriveBy time.Time

func (ArriveBy) IsZero

func (t ArriveBy) IsZero() bool

type BannerInstruction

type BannerInstruction struct {
	DistanceAlongGeometry float64      `json:"distanceAlongGeometry"` // The distance from the current step at which to show the instruction.
	Primary               Instruction  `json:"primary"`               // The primary instruction for this step.
	Secondary             *Instruction `json:"secondary,omitempty"`   // An optional secondary instruction.
}

BannerInstruction represents a visual instruction for navigation.

type BoundingBox

type BoundingBox struct {
	Min Coordinate
	Max Coordinate
}

type Client

type Client struct {

	// Referer is needed when URL restrictions are enforced, see https://docs.mapbox.com/accounts/guides/tokens/#url-restrictions
	Referer string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config *MapboxConfig) (*Client, error)

NewClient instantiates a new Mapbox client.

func (*Client) Directions

func (c *Client) Directions(ctx context.Context, req *DirectionsRequest) (*DirectionsResponse, error)

func (*Client) DirectionsMatrix

func (c *Client) DirectionsMatrix(ctx context.Context, req *DirectionsMatrixRequest) (*DirectionsMatrixResponse, error)

func (*Client) ForwardGeocode

func (c *Client) ForwardGeocode(ctx context.Context, req *ForwardGeocodeRequest) (*GeocodeResponse, error)

func (*Client) ForwardGeocodeBatch

func (c *Client) ForwardGeocodeBatch(ctx context.Context, req ForwardGeocodeBatchRequest) (*GeocodeBatchResponse, error)

func (*Client) ReverseGeocode

func (c *Client) ReverseGeocode(ctx context.Context, req *ReverseGeocodeRequest) (*GeocodeResponse, error)

func (*Client) ReverseGeocodeBatch

func (c *Client) ReverseGeocodeBatch(ctx context.Context, req ReverseGeocodeBatchRequest) (*GeocodeBatchResponse, error)

func (*Client) SearchboxReverse

func (c *Client) SearchboxReverse(ctx context.Context, req *SearchboxReverseRequest) (*SearchboxReverseResponse, error)

type Component

type Component struct {
	Text string `json:"text"` // The component text.
	Type string `json:"type"` // The type of component, e.g., "text" or "icon".
}

Component represents a part of the instruction, useful for highlighting parts of the text.

type Context

type Context struct {
	// Always present
	MapboxID string `json:"mapbox_id"`
	Name     string `json:"name"`

	// Optional but shared between many context types
	WikidataID string `json:"wikidata_id,omitempty"`

	// Region fields
	RegionCode     string `json:"region_code,omitempty"`
	RegionCodeFull string `json:"region_code_full,omitempty"`

	// Address fields
	AddressNumber string `json:"address_number,omitempty"`
	StreetName    string `json:"street_name,omitempty"`

	// Country fields
	CountryCode       string `json:"country_code,omitempty"`
	CountryCodeAlpha3 string `json:"country_code_alpha_3,omitempty"`
}

There are many different types of context objects, which are all mashed together here. https://docs.mapbox.com/api/search/geocoding/#the-context-object

type Coordinate

type Coordinate struct {
	Lat float64 `json:"latitude"`
	Lng float64 `json:"longitude"`
}

func (Coordinate) IsZero

func (c Coordinate) IsZero() bool

type Coordinates

type Coordinates []Coordinate

type DepartAt

type DepartAt time.Time

func (DepartAt) IsZero

func (t DepartAt) IsZero() bool

type DepartureTime

type DepartureTime time.Time

func (DepartureTime) IsZero

func (t DepartureTime) IsZero() bool

type Destinations

type Destinations []int

type DirectionWaypoint

type DirectionWaypoint string

type DirectionWaypoints

type DirectionWaypoints []DirectionWaypoint

type DirectionsAnnotation

type DirectionsAnnotation struct {
	Distance   []float64  `json:"distance"`   // Array of distances between each pair of coordinates.
	Duration   []float64  `json:"duration"`   // Array of expected travel times from each coordinate to the next.
	Speed      []float64  `json:"speed"`      // Array of travel speeds.
	Congestion []string   `json:"congestion"` // Array of congestion levels.
	Maxspeed   []Maxspeed `json:"maxspeed"`
}

Annotation contains additional details about each point along the route leg.

type DirectionsMatrixRequest

type DirectionsMatrixRequest struct {
	// required
	Profile     Profile
	Coordinates Coordinates

	// optional
	Annotations   Annotations
	Approaches    Approaches
	Destinations  Destinations
	Sources       Sources
	FallbackSpeed FallbackSpeed
	DepartureTime DepartureTime
}

type DirectionsMatrixResponse

type DirectionsMatrixResponse struct {
	Code         string       `json:"code"`
	Durations    [][]*float64 `json:"durations"`
	Distances    [][]*float64 `json:"distances"`
	Destinations []Waypoint   `json:"destinations"`
	Sources      []Waypoint   `json:"sources"`
}

type DirectionsRequest

type DirectionsRequest struct {
	// required
	Profile     Profile
	Coordinates Coordinates

	// optional
	Alternatives        *bool
	Annotations         Annotations
	AvoidManeuverRadius int // Possible values are in the range from 1 to 1000
	ContinueStraight    *bool
	Excludes            Excludes
	Geometries          Geometries
	Includes            Includes
	Overview            Overview
	Approaches          Approaches
	Steps               *bool
	BannerInstructions  *bool
	Language            string
	RoundaboutExits     *bool
	VoiceInstructions   *bool
	VoiceUnits          VoiceUnits
	Waypoints           DirectionWaypoints
	WaypointsPerRoute   *bool
	WaypointNames       WaypointNames
	WaypointTargets     WaypointTargets

	// Optional parameters for the mapbox/walking profile
	WalkingSpeed float32
	WalkwayBias  float32

	// Optional parameters for the mapbox/driving profile
	AlleyBias float32
	ArriveBy  ArriveBy
	DepartAt  DepartAt
	MaxHeight int
	MaxWidth  int
	MaxWeight int

	// Optional parameters for the mapbox/driving-traffic profile
	SnappingIncludeClosures       *bool
	SnappingIncludeStaticClosures *bool
}

type DirectionsResponse

type DirectionsResponse struct {
	Code   string  `json:"code"`
	UUID   string  `json:"uuid,omitempty"`
	Routes []Route `json:"routes"`
}

type Endpoint

type Endpoint string

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message"`
	Code    string `json:"code"`
}

type Exclude

type Exclude string

type Excludes

type Excludes []Exclude

type ExtendedCoordinate

type ExtendedCoordinate struct {
	Latitude       float64         `json:"latitude"`
	Longitude      float64         `json:"longitude"`
	Accuracy       string          `json:"accuracy"`
	RoutablePoints []RoutablePoint `json:"routable_points,omitempty"`
}

type FallbackSpeed

type FallbackSpeed float64

type Feature

type Feature struct {
	ID         string      `json:"id"`
	Type       string      `json:"type"`
	Geometry   *Geometry   `json:"geometry"` // The center of Properties.BoundingBox
	Properties *Properties `json:"properties,omitempty"`
}

type ForwardGeocodeBatchRequest

type ForwardGeocodeBatchRequest []ForwardGeocodeRequest

type ForwardGeocodeBatchResponse

type ForwardGeocodeBatchResponse struct {
	Batch []GeocodeResponse `json:"batch"`
}

type ForwardGeocodeRequest

type ForwardGeocodeRequest struct {
	SearchText   string
	AddressLine1 string
	Postcode     string
	Place        string
	Autocomplete bool
	BBox         BoundingBox
	Country      string
	Language     string
	Limit        int
	Proximity    Coordinate
	Types        Types
}

func (ForwardGeocodeRequest) MarshalJSON

func (r ForwardGeocodeRequest) MarshalJSON() ([]byte, error)

type GeocodeBatchResponse

type GeocodeBatchResponse struct {
	Batch []GeocodeResponse `json:"batch"`
}

type GeocodeResponse

type GeocodeResponse struct {
	Type        string     `json:"type"`
	Features    []*Feature `json:"features"`
	Attribution string     `json:"attribution"`
}

type Geometries

type Geometries string

type Geometry

type Geometry struct {
	Coordinates []float64 `json:"coordinates"` // [lng, lat]
	Type        string    `json:"type"`
}

func (Geometry) Latitude

func (g Geometry) Latitude() float64

func (Geometry) Longitude

func (g Geometry) Longitude() float64

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

type Include

type Include string

type Includes

type Includes []Include

type Instruction

type Instruction struct {
	Text       string      `json:"text"`       // The instruction text.
	Type       string      `json:"type"`       // The type of maneuver.
	Modifier   string      `json:"modifier"`   // An additional modifier to provide more detail.
	Components []Component `json:"components"` // Components of the instruction.
}

Instruction contains the details of a navigation instruction.

type Intersection

type Intersection struct {
	Location []float64 `json:"location"`      // The location of the intersection [longitude, latitude].
	Bearings []int     `json:"bearings"`      // The bearings at the intersection, in degrees.
	Entry    []bool    `json:"entry"`         // A boolean flag indicating the availability of the corresponding bearing.
	In       int       `json:"in,omitempty"`  // The index into the bearings/entry array that denotes the incoming bearing to the intersection.
	Out      int       `json:"out,omitempty"` // The index into the bearings/entry array that denotes the outgoing bearing from the intersection.
}

Intersection represents an intersection along a step.

type Maneuver

type Maneuver struct {
	BearingAfter  float64   `json:"bearing_after"`  // The clockwise angle from true north to the direction of travel after the maneuver.
	BearingBefore float64   `json:"bearing_before"` // The clockwise angle from true north to the direction of travel before the maneuver.
	Location      []float64 `json:"location"`       // A [longitude, latitude] pair describing the location of the maneuver.
	Type          string    `json:"type"`           // A string signifying the type of maneuver. Example: "turn".
	Modifier      string    `json:"modifier"`       // An additional modifier to provide more detail. Example: "left".
	Instruction   string    `json:"instruction"`    // Verbal instruction for the maneuver.
}

Maneuver contains information about the required maneuver for a step, including type and bearing.

type MapboxConfig

type MapboxConfig struct {
	Timeout time.Duration
	APIKey  string

	// Optional http.Client can be defined in config if specific options are needed
	// If not provided will default to the stdlib http.Client
	Client HTTPClient
}

type MapboxError

type MapboxError struct {
	StatusCode int    `json:"status_code"`
	Message    string `json:"error"`
}

func NewMapboxError

func NewMapboxError(statusCode int, message string) MapboxError

func (MapboxError) Error

func (e MapboxError) Error() string

type MatchCode

type MatchCode struct {
	AddressNumber MatchCodeValue      `json:"address_number"`
	Street        MatchCodeValue      `json:"street"`
	Postcode      MatchCodeValue      `json:"postcode"`
	Place         MatchCodeValue      `json:"place"`
	Region        MatchCodeValue      `json:"region"`
	Locality      MatchCodeValue      `json:"locality"`
	Country       MatchCodeValue      `json:"country"`
	Confidence    MatchCodeConfidence `json:"confidence"`
}

type MatchCodeConfidence

type MatchCodeConfidence string

type MatchCodeValue

type MatchCodeValue string

type Maxspeed

type Maxspeed struct {
	Speed int    `json:"speed"`
	Unit  string `json:"unit"`
}

type Overview

type Overview string

type Profile

type Profile string

type Properties

type Properties struct {
	MapboxID       string             `json:"mapbox_id"`
	FeatureType    Type               `json:"feature_type"`
	Name           string             `json:"name"`
	NamePreferred  string             `json:"name_preferred"`
	PlaceFormatted string             `json:"place_formatted"`
	FullAddress    string             `json:"full_address"`
	Coordinates    ExtendedCoordinate `json:"coordinates"`
	Context        map[Type]Context   `json:"context,omitempty"`
	BoundingBox    []float64          `json:"bbox,omitempty"`
	MatchCode      *MatchCode         `json:"match_code,omitempty"`
}

type RateLimit

type RateLimit string

RateLimit represents a set of operations that share a rate limit see https://docs.mapbox.com/api/overview/#rate-limits

type ReverseGeocodeBatchRequest

type ReverseGeocodeBatchRequest []ReverseGeocodeRequest

type ReverseGeocodeRequest

type ReverseGeocodeRequest struct {
	Coordinate

	// optional
	Country  string `json:"country,omitempty"`
	Language string `json:"language,omitempty"`
	Limit    int    `json:"limit,omitempty"`
	Types    Types  `json:"types,omitempty"`
}

type RoutablePoint

type RoutablePoint struct {
	Name      string
	Latitude  float64
	Longitude float64
}

type Route

type Route struct {
	Duration        float64    `json:"duration"`
	Distance        float64    `json:"distance"`
	WeightName      string     `json:"weight_name"`
	Weight          float64    `json:"weight"`
	DurationTypical float64    `json:"duration_typical,omitempty"`
	WeightTypical   float64    `json:"weight_typical,omitempty"`
	Geometry        string     `json:"geometry,omitempty"`
	Legs            []RouteLeg `json:"legs"`
	VoiceLocale     string     `json:"voiceLocale,omitempty"`
	Waypoints       []Waypoint `json:"waypoints,omitempty"`
}

type RouteLeg

type RouteLeg struct {
	Distance           float64              `json:"distance"`           // The distance traveled by the leg, in meters.
	Duration           float64              `json:"duration"`           // The estimated travel time, in seconds.
	Summary            string               `json:"summary"`            // A summary of the leg, containing the names of the significant roads.
	Weight             float64              `json:"weight"`             // The weight of the leg. The weight value is similar to the duration but includes additional factors like traffic.
	Steps              []Step               `json:"steps"`              // An array of RouteStep objects, each representing a step in the leg.
	Annotation         DirectionsAnnotation `json:"annotation"`         // Additional details about the leg.
	Admins             []Admin              `json:"admins"`             // Array of administrative region objects traversed by the leg.
	VoiceInstructions  []VoiceInstruction   `json:"voiceInstructions"`  // An array of VoiceInstruction objects.
	BannerInstructions []BannerInstruction  `json:"bannerInstructions"` // An array of BannerInstruction objects.
	ViaWaypoints       []ViaWaypoint        `json:"via_waypoints"`
}

RouteLeg represents a leg of the route between two waypoints.

type SearchboxReverseFeature

type SearchboxReverseFeature struct {
	ID         string                      `json:"id"`
	Type       string                      `json:"type"`
	Geometry   *Geometry                   `json:"geometry"`
	Properties *SearchboxReverseProperties `json:"properties,omitempty"`
}

type SearchboxReverseProperties

type SearchboxReverseProperties struct {
	MapboxID       string                 `json:"mapbox_id"`
	FeatureType    Type                   `json:"feature_type"`
	Name           string                 `json:"name"`
	NamePreferred  string                 `json:"name_preferred"`
	PlaceFormatted string                 `json:"place_formatted"`
	FullAddress    string                 `json:"full_address"`
	Coordinates    ExtendedCoordinate     `json:"coordinates"`
	Context        map[Type]Context       `json:"context,omitempty"`
	BoundingBox    []float64              `json:"bbox,omitempty"`
	Language       string                 `json:"language"`
	Maki           string                 `json:"maki"`
	POICategory    []string               `json:"poi_category"`
	POICategoryIDs []string               `json:"poi_category_ids"`
	Brand          []string               `json:"brand"`
	BrandID        []string               `json:"brand_id"`
	ExternalIDs    map[string]string      `json:"external_ids,omitempty"`
	Metadata       map[string]interface{} `json:"metadata,omitempty"`
}

type SearchboxReverseRequest

type SearchboxReverseRequest struct {
	Coordinate

	// optional
	Country  string `json:"country,omitempty"`
	Language string `json:"language,omitempty"`
	Limit    int    `json:"limit,omitempty"`
	Types    Types  `json:"types,omitempty"`
}

type SearchboxReverseResponse

type SearchboxReverseResponse struct {
	Type        string                     `json:"type"`
	Features    []*SearchboxReverseFeature `json:"features"`
	Attribution string                     `json:"attribution"`
}

type Sources

type Sources []int

type Step

type Step struct {
	Distance      float64        `json:"distance"`      // The distance for this step in meters.
	Duration      float64        `json:"duration"`      // The estimated travel time for this step in seconds.
	Geometry      string         `json:"geometry"`      // An encoded polyline string or GeoJSON LineString representing the step geometry.
	Name          string         `json:"name"`          // The name of the road or path used in the step.
	Maneuver      Maneuver       `json:"maneuver"`      // The maneuver required to move from this step to the next.
	Mode          string         `json:"mode"`          // The travel mode of the step.
	Weight        float64        `json:"weight"`        // Similar to duration but includes additional factors like traffic.
	Intersections []Intersection `json:"intersections"` // An array of Intersection objects.
}

Step represents a single step in a leg of a route, containing maneuver instructions and distance/duration.

type Type

type Type string

type Types

type Types []Type

type ViaWaypoint

type ViaWaypoint struct {
	WaypointIndex     int     `json:"waypoint_index"`
	DistanceFromStart float64 `json:"distance_from_start"`
	GeometryIndex     int     `json:"geometry_index"`
}

type VoiceInstruction

type VoiceInstruction struct {
	DistanceAlongGeometry float64 `json:"distanceAlongGeometry"` // The distance from the current step at which to provide the instruction.
	Announcement          string  `json:"announcement"`          // The verbal instruction.
	SSMLAnnouncement      string  `json:"ssmlAnnouncement"`      // The instruction in SSML format for text-to-speech engines.
}

VoiceInstruction represents a single voice instruction for navigation.

type VoiceUnits

type VoiceUnits string

type Waypoint

type Waypoint struct {
	Distance float64 `json:"distance"`
	Name     string  `json:"name"`
	Location []float64
}

type WaypointName

type WaypointName string

type WaypointNames

type WaypointNames []WaypointName

type WaypointTarget

type WaypointTarget string

type WaypointTargets

type WaypointTargets []WaypointTarget

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL