am

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2023 License: MIT Imports: 14 Imported by: 0

README

am: Apple Maps Server API SDK for Go Go Reference

go install github.com/ringsaturn/am

Usage

Create a client
package main

import (
	"fmt"

	"github.com/ringsaturn/am"
)

func main() {
	client := am.NewClient("your_auth_token")
	fmt.Println(client)
}

Documentation

Index

Examples

Constants

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessTokenResponse

type AccessTokenResponse struct {
	AccessToken      string `json:"accessToken"`
	ExpiresInSeconds int64  `json:"expiresInSeconds"`
}

https://developer.apple.com/documentation/applemapsserverapi/generate_a_maps_access_token

type AccessTokenSaver

type AccessTokenSaver interface {
	GetAccessToken(context.Context) (string, int64, error)
	SetAccessToken(context.Context, string, int64) error
}

AccessTokenSaver is an interface to save and get access token.

Please implement this interface if you want to save access token in Redis or other places.

type AutoRefresh

type AutoRefresh func(ctx context.Context, client Client) (string, int64, error)

AutoRefresh is a function to refresh access token based on token expire time.

type AutocompleteResult

type AutocompleteResult struct {
	// The relative URI to the search endpoint to use to fetch more details
	// pertaining to the result. If available, the framework encodes opaque data
	// about the autocomplete result in the completion URL’s metadata parameter.
	// If clients need to fetch the search result in a certain language, they’re
	// responsible for specifying the lang parameter in the request.
	CompletionURL string `json:"completionUrl"`

	// A JSON string array to use to create a long form of display text for the
	// completion result.
	DisplayLines []string `json:"displayLines"`

	// A Location object that specifies the location for the request in terms of
	// its latitude and longitude.
	Location Location `json:"location"`

	// A StructuredAddress object that describes the detailed address components
	// of a place.
	StructuredAddress StructuredAddress `json:"structuredAddress"`
}

https://developer.apple.com/documentation/applemapsserverapi/autocompleteresult

type Client

func NewClient

func NewClient(authToken string, opts ...Option) Client
Example
package main

import (
	"context"
	"fmt"
	"net/http"
	"sync"

	"github.com/ringsaturn/am"
)

type FooTokenSaver struct {
	token string
	exp   int64
	mutex sync.Mutex
}

func (s *FooTokenSaver) GetAccessToken(context.Context) (string, int64, error) {
	s.mutex.Lock()
	defer s.mutex.Unlock()
	return s.token, s.exp, nil
}

func (s *FooTokenSaver) SetAccessToken(ctx context.Context, token string, exp int64) error {
	s.mutex.Lock()
	defer s.mutex.Unlock()
	s.token = token
	s.exp = exp
	return nil
}

func main() {
	simpleClient := am.NewClient("your_auth_token")
	fmt.Println(simpleClient)

	customSaverClient := am.NewClient("your_auth_token", am.WithTokenSaver(&FooTokenSaver{}))
	fmt.Println(customSaverClient)

	customHTTP := &http.Client{
		Timeout: 10,
	}
	customHTTPClient := am.NewClient("your_auth_token", am.WithHTTPClient(customHTTP))
	fmt.Println(customHTTPClient)
}
Output:

type DirectionsAvoid

type DirectionsAvoid string
const (
	// When you set avoid=Tolls, routes without tolls are higher up in the list
	// of returned routes. Note that even when you set avoid=Tolls, the routes
	// the server returns may contain tolls (if no reasonable toll-free routes
	// exist). Ensure you check the value of routes[i].hasTolls in the response
	// to verify toll assumptions.
	DirectionsAvoidTolls DirectionsAvoid = "Tolls"
)

type DirectionsRequest

type DirectionsRequest struct {
	// (Required) The starting location as an address, or coordinates you
	// specify as latitude, longitude. For example, origin=37.7857,-122.4011
	Origin OneOfLoc `query:"origin" vd:"$!=''"`

	// (Required) The destination as an address, or coordinates you specify as
	// latitude, longitude. For example, destination=San Francisco City Hall, CA
	Destination OneOfLoc `query:"destination" vd:"$!=''"`

	// The date and time to arrive at the destination in ISO 8601 format in UTC
	// time. For example, 2023-04-15T16:42:00Z.
	//
	// You can specify only arrivalDate or departureDate. If you don’t specify
	// either option, the departureDate defaults to now, which the server
	// interprets as the current time.
	ArrivalDate time.Time `query:"arrivalDate"`

	// A comma-separated list of the features to avoid when calculating
	// direction routes. For example, avoid=Tolls.
	// See DirectionsAvoid for a complete list of possible values.
	Avoid []DirectionsAvoid `query:"avoid"`

	// The date and time to depart from the origin in ISO 8601 format in UTC time.
	// For example, 2023-04-15T16:42:00Z.
	// You can only specify arrivalDate or departureDate. If you don’t specify
	// either option, the departureDate defaults to now, which the server
	// interprets as the current time.
	DepartureDate time.Time `query:"departureDate"`

	// The language the server uses when returning the response, specified using
	// a BCP 47 language code. For example, for English, use lang=en-US.
	// Default: en-US
	Lang language.Tag `query:"lang"`

	// When you set this to true, the server returns additional routes, when
	// available. For example, requestsAlternateRoutes=true.
	// Default: false
	RequestsAlternateRoutes bool `query:"requestsAlternateRoutes"`

	// A searchLocation the app defines as a hint for the query input for origin
	// or destination. Specify the location as a comma-separated string that
	// contains the latitude and longitude. For example, 37.7857,-122.4011.
	// If you don’t provide a searchLocation, the server uses userLocation and
	// searchLocation as fallback hints.
	SearchLocation Location `query:"searchLocation"`

	// A region the app defines as a hint for the query input for origin or
	// destination. Specify the region as a comma-separated string that
	// describes the region in the form of a north-latitude, east-longitude,
	// south-latitude, west-longitude string. For example, 38,-122.1,37.5,-122.5.
	// If you don’t provide a searchLocation, the server uses userLocation and
	// searchRegion as fallback hints.
	SearchRegion Region `query:"searchRegion"`

	// The mode of transportation the server returns directions for.
	// Default: Automobile
	// Possible Values: Automobile, Walking
	TransportType TransportType `query:"transportType"`

	// The location of the user, specified as a comma-separated string that
	// contains the latitude and longitude. For example, userLocation=37.78,-122.42.
	// If you don’t provide a searchLocation, the server uses userLocation and
	// searchRegion as fallback hints.
	UserLocation Location `query:"userLocation"`
}

func (*DirectionsRequest) URLValues

func (req *DirectionsRequest) URLValues() (url.Values, error)

func (*DirectionsRequest) Validate

func (req *DirectionsRequest) Validate() error

type DirectionsResponse

type DirectionsResponse struct {
	// A Place object that describes the destination.
	Destination Place `json:"destination"`

	// A Place result that describes the origin.
	Origin Place `json:"origin"`

	// An array of routes. Each route references steps based on indexes into the steps array.
	Routes []DirectionsResponseRoute `json:"routes"`

	// An array of step paths across all steps across all routes. Each step path
	// is a single polyline represented as an array of points. You reference the
	// step paths by index into the array.
	StepPaths [][]Location `json:"stepPaths"`

	// An array of all steps across all routes. You reference the route steps by
	// index into this array. Each step in turn references its path based on
	// indexes into the stepPaths array.
	Steps []DirectionsResponseStep `json:"steps"`
}

https://developer.apple.com/documentation/applemapsserverapi/directionsresponse

type DirectionsResponseRoute

type DirectionsResponseRoute struct {
	// Total distance that the route covers, in meters.
	DistanceMeters int64 `json:"distanceMeters"`
	// The estimated time to traverse this route in seconds. If you’ve specified
	// a departureDate or arrivalDate, then the estimated time includes traffic
	// conditions assuming user departs or arrives at that time.
	//
	// If you set neither departureDate or arrivalDate, then estimated time
	// represents current traffic conditions assuming user departs “now” from
	// the point of origin.
	DurationSeconds int64 `json:"durationSeconds"`

	// When true, this route has tolls; if false, this route has no tolls.
	// If the value isn’t defined (”undefined”), the route may or may not have tolls.
	HasTolls bool `json:"hasTolls"`

	// The route name that you can use for display purposes.
	Name string `json:"name"`

	// An array of integer values that you can use to determine the number steps
	// along this route. Each value in the array corresponds to an index into
	// the steps array.
	StepIndexes []int64 `json:"stepIndexes"`

	// A string that represents the mode of transportation the service used to
	// estimate the arrival time. Same as the input query param transportType or
	// Automobile if the input query didn’t specify a transportation type.
	// Possible Values: Automobile, Walking
	TransportType TransportType `json:"transportType"`
}

type DirectionsResponseStep

type DirectionsResponseStep struct {
	// Total distance covered by the step, in meters.
	DistanceMeters int64 `json:"distanceMeters"`

	// The estimated time to traverse this step, in seconds.
	DurationSeconds int64 `json:"durationSeconds"`

	// The localized instruction string for this step that you can use for display purposes.
	// You can specify the language to receive the response in using the lang parameter.
	Instructions string `json:"instructions"`

	// A pointer to this step’s path. The pointer is in the form of an index
	// into the stepPaths array contained in a Route.
	// Step paths are self-contained which implies that the last point of a
	// previous step path along a route is the same as the first point of the
	// next step path. Clients are responsible for avoiding duplication when
	// rendering the point.
	StepPathIndex int64 `json:"stepPathIndex"`

	// A string indicating the transport type for this step if it’s different
	// from the transportType in the route.
	// Possible Values: Automobile, Walking
	TransportType TransportType `json:"transportType"`
}

type ErrorFromAPI

type ErrorFromAPI struct {
	StatusCode int            `json:"statusCode"`
	Response   *ErrorResponse `json:"response"`
	RawBody    []byte         `json:"body"`
	Header     http.Header    `json:"headers"`
}

func (*ErrorFromAPI) Error

func (e *ErrorFromAPI) Error() string

type ErrorResponse

type ErrorResponse struct {
	Error ErrorResponseError `json:"error"`
}

Original response from API.

https://developer.apple.com/documentation/applemapsserverapi/errorresponse

type ErrorResponseError

type ErrorResponseError struct {
	Details []string `json:"details"`
	Message string   `json:"message"`
}

type EtaRequest

type EtaRequest struct {
	// (Required) The starting point for estimated arrival time requests,
	// specified as a comma-separated string that contains the latitude and
	// longitude. For example, origin=37.331423,-122.030503.
	Origin Location `query:"origin"`

	// (Required) Destination coordinates represented as pairs of latitude and
	// longitude separated by a vertical bar character (”|”).
	// For example, destinations=37.32556561130194,-121.94635203581443|37.44176585512703,-122.17259315798667.
	// The parameter must specify at least one destination coordinate, but no
	// more than 10 destinations. Specify the location as a comma-separated
	// string that contains the latitude and longitude.
	Destinations []Location `query:"destinations"`

	// The mode of transportation to use when estimating arrival times.
	// Default: Automobile
	// Possible Values: Automobile, Transit, Walking
	TransportType EtasTransportType `query:"transportType"`

	// The time of departure to use in an estimated arrival time request, in ISO
	// 8601 format in UTC time.
	//
	// For example, departureDate=2020-09-15T16:42:00Z.
	// If you don’t specify a departure date, the server uses the current date
	// and time when you make the request.
	DepartureDate time.Time `query:"departureDate"`

	// The intended time of arrival in ISO 8601 format in UTC time.
	ArrivalDate time.Time `query:"arrivalDate"`
}

func (*EtaRequest) URLValues

func (req *EtaRequest) URLValues() (url.Values, error)

func (*EtaRequest) Validate

func (req *EtaRequest) Validate() error

type EtaResponse

type EtaResponse struct {
	// An array of one or more EtaResponse.Eta objects.
	Etas []EtaResponseEta `json:"etas"`
}

https://developer.apple.com/documentation/applemapsserverapi/etaresponse

type EtaResponseEta

type EtaResponseEta struct {
	// The destination as a Location.
	Destination Location `json:"destination"`

	// The distance in meters to the destination.
	DistanceMeters int64 `json:"distanceMeters"`

	// The estimated travel time in seconds, including delays due to traffic.
	ExpectedTravelTimeSeconds int64 `json:"expectedTravelTimeSeconds"`

	// The expected travel time, in seconds, without traffic.
	StaticTravelTimeSeconds int64 `json:"staticTravelTimeSeconds"`

	// A string that represents the mode of transportation for this ETA, which is one of:
	// Automobile, Walking, Transit
	//
	// NOTE(ringsaturn): Apple's example use `AUTOMOBILE`, who knows why.
	TransportType TransportType `json:"transportType"`
}

https://developer.apple.com/documentation/applemapsserverapi/etaresponse/eta

type EtasTransportType

type EtasTransportType string

https://developer.apple.com/documentation/applemapsserverapi/determine_estimated_arrival_times_and_distances_to_one_or_more_destinations

const (
	EtasTransportTypeAutomobile EtasTransportType = "Automobile"
	EtasTransportTypeWalking    EtasTransportType = "Walking"

	// Ask Apple why this not in direction API
	EtasTransportTypeTransit EtasTransportType = "Transit"
)

type GeocodeRequest

type GeocodeRequest struct {
	// (Required) The address to geocode. For example: q=1 Apple Park, Cupertino, CA
	Query string `query:"q" vd:"$!=''"`

	// A comma-separated list of two-letter ISO 3166-1 codes to limit the results to.
	// For example: limitToCountries=US,CA.
	//
	// If you specify two or more countries, the results reflect the best
	// available results for some or all of the countries rather than everything
	// related to the query for those countries.
	LimitToCountries []countries.CountryCode `query:"limitToCountries,omitempty"`

	// The language the server should use when returning the response, specified
	// using a BCP 47 language code. For example, for English use lang=en-US.
	//
	// Default: en-US
	Lang language.Tag `query:"lang"`

	// A location defined by the application as a hint. Specify the location as
	// a comma-separated string containing the latitude and longitude.
	// For example, searchLocation=37.78,-122.42.
	SearchLocation Location `query:"searchLocation,omitempty"`

	// A region the app defines as a hint. Specify the region specified as a
	// comma-separated string that describes the region in the form
	// north-latitude, east-longitude, south-latitude, west-longitude.
	// For example, searchRegion=38,-122.1,37.5,-122.5.
	SearchRegion Region `query:"searchRegion,omitempty"`

	// The location of the user, specified as a comma-separated string that
	// contains the latitude and longitude.
	// For example: userLocation=37.78,-122.42.
	//
	// Certain APIs, such as Searching, may opt to
	// use the userLocation, if specified, as a fallback for the searchLocation.
	UserLocation Location `query:"userLocation,omitempty"`
}

https://developer.apple.com/documentation/applemapsserverapi/geocode_an_address

func (*GeocodeRequest) URLValues

func (req *GeocodeRequest) URLValues() (url.Values, error)

func (*GeocodeRequest) Validate

func (req *GeocodeRequest) Validate() error

type Location

type Location struct {
	Latitude  float64 `query:"latitude" json:"latitude" vd:"$>=-90 && $<=90"`
	Longitude float64 `query:"longitude" json:"longitude" vd:"$>=-180 && $<=180"`
}

func (Location) IsEmpty

func (Location Location) IsEmpty() bool

func (Location) QueryString

func (location Location) QueryString() string

searchLocation=37.78,-122.42.

type MapRegion

type MapRegion = Region

type OneOfLoc

type OneOfLoc struct {
	Address  string
	Location *Location
}

func (*OneOfLoc) IsEmpty

func (loc *OneOfLoc) IsEmpty() bool

func (*OneOfLoc) QueryString

func (loc *OneOfLoc) QueryString() string

type Option

type Option func(*baseClient)

func WithAutoTokenRefresh

func WithAutoTokenRefresh(fn AutoRefresh) Option

Will use `defaultAutoRefresh`(an internal function) by default. If you want to disable auto refresh, please set this option to nil.

If you want to implement your own auto refresh function, please make sure the function is thread safe. Because the function could be called by multiple goroutines.

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

Will use http.DefaultClient by default.

func WithTokenSaver

func WithTokenSaver(saver AccessTokenSaver) Option

Will use `memorySaver`(an internal function) default.

Please implement your own `AccessTokenSaver` if you want to save access token in Redis or other places.

type Place

type Place struct {
	// The country or region of the place.
	Country string `json:"country"`

	// The 2-letter country code of the place.
	CountryCode string `json:"countryCode"`

	// The geographic region associated with the place.
	//
	// This is a rectangular region on a map expressed as south-west and
	// north-east points. Specifically south latitude, west longitude,
	// north latitude, and east longitude.
	DisplayMapRegion MapRegion `json:"displayMapRegion"`

	// The address of the place, formatted using its conventions of its country
	// or region.
	FormattedAddressLines []string `json:"formattedAddressLines"`

	// A place name that you can use for display purposes.
	Name string `json:"name"`

	// The latitude and longitude of this place.
	Coordinate Location `json:"coordinate"`

	// A StructuredAddress object that describes details of the place’s address.
	StructuredAddress StructuredAddress `json:"structuredAddress"`
}

https://developer.apple.com/documentation/applemapsserverapi/place

type PlaceResults

type PlaceResults struct {
	Results []Place `json:"results"`
}

type PoiCategory

type PoiCategory string

PoiCategory: 'A string that describes a specific point of interest (POI) category.' https://developer.apple.com/documentation/applemapsserverapi/poicategory

const (
	Airport         PoiCategory = "Airport"         // An airport.
	AirportGate     PoiCategory = "AirportGate"     // A specific gate at an airport.
	AirportTerminal PoiCategory = "AirportTerminal" // A specific named terminal at an airport.
	AmusementPark   PoiCategory = "AmusementPark"   // An amusement park.
	ATM             PoiCategory = "ATM"             // An automated teller machine.
	Aquarium        PoiCategory = "Aquarium"        // An aquarium.
	Bakery          PoiCategory = "Bakery"          // A bakery.
	Bank            PoiCategory = "Bank"            // A bank.
	Beach           PoiCategory = "Beach"           // A beach.
	Brewery         PoiCategory = "Brewery"         // A brewery.
	Cafe            PoiCategory = "Cafe"            // A cafe.
	Campground      PoiCategory = "Campground"      // A campground.
	CarRental       PoiCategory = "CarRental"       // A car rental location.
	EVCharger       PoiCategory = "EVCharger"       // An electric vehicle (EV) charger.
	FireStation     PoiCategory = "FireStation"     // A fire station.
	FitnessCenter   PoiCategory = "FitnessCenter"   // A fitness center.
	FoodMarket      PoiCategory = "FoodMarket"      // A food market.
	GasStation      PoiCategory = "GasStation"      // A gas station.
	Hospital        PoiCategory = "Hospital"        // A hospital.
	Hotel           PoiCategory = "Hotel"           // A hotel.
	Laundry         PoiCategory = "Laundry"         // A laundry.
	Library         PoiCategory = "Library"         // A library.
	Marina          PoiCategory = "Marina"          // A marina.
	MovieTheater    PoiCategory = "MovieTheater"    // A movie theater.
	Museum          PoiCategory = "Museum"          // A museum.
	NationalPark    PoiCategory = "NationalPark"    // A national park.
	Nightlife       PoiCategory = "Nightlife"       // A night life venue.
	Park            PoiCategory = "Park"            // A park.
	Parking         PoiCategory = "Parking"         // A parking location for an automobile.
	Pharmacy        PoiCategory = "Pharmacy"        // A pharmacy.
	Playground      PoiCategory = "Playground"      // A playground.
	Police          PoiCategory = "Police"          // A police station.
	PostOffice      PoiCategory = "PostOffice"      // A post office.
	PublicTransport PoiCategory = "PublicTransport" // A public transportation station.
	ReligiousSite   PoiCategory = "ReligiousSite"   // A religious site.
	Restaurant      PoiCategory = "Restaurant"      // A restaurant.
	Restroom        PoiCategory = "Restroom"        // A restroom.
	School          PoiCategory = "School"          // A school.
	Stadium         PoiCategory = "Stadium"         // A stadium.
	Store           PoiCategory = "Store"           // A store.
	Theater         PoiCategory = "Theater"         // A theater.
	University      PoiCategory = "University"      // A university.
	Winery          PoiCategory = "Winery"          // A winery.
	Zoo             PoiCategory = "Zoo"             // A zoo.
)

Codes generated via ChatGPT

type Region

type Region struct {
	EastLongitude float64 `json:"eastLongitude" query:"eastLongitude" vd:"$>=-180 && $<=180"`
	NorthLatitude float64 `json:"northLatitude" query:"northLatitude" vd:"$>=-90 && $<=90"`
	SouthLatitude float64 `json:"southLatitude" query:"southLatitude" vd:"$>=-90 && $<=90"`
	WestLongitude float64 `json:"westLongitude" query:"westLongitude" vd:"$>=-180 && $<=180"`
}

func (Region) IsEmpty

func (region Region) IsEmpty() bool

func (Region) QueryString

func (region Region) QueryString() string

Region order as: north-latitude, east-longitude, south-latitude, west-longitude. For example, searchRegion=38,-122.1,37.5,-122.5.

type ReverseRequest

type ReverseRequest struct {
	// (Required) The coordinate to reverse geocode as a comma-separated string
	// that contains the latitude and longitude. For example: loc=37.3316851,-122.0300674.
	Loc Location `query:"loc"`

	// The language the server uses when returning the response, specified using
	// a BCP 47 language code. For example, for English, use lang=en-US.
	// Default: en-US
	Lang language.Tag `query:"lang"`
}

func (*ReverseRequest) URLValues

func (req *ReverseRequest) URLValues() (url.Values, error)

func (*ReverseRequest) Validate

func (req *ReverseRequest) Validate() error

type SearchAutoCompleteRequest

type SearchAutoCompleteRequest struct {
	// (Required) The query to autocomplete. For example, q=eiffel.
	Query string `query:"q" vd:"$!=''"`

	// A comma-separated list of strings that describes the points of interest
	// to exclude from the search results.
	// For example, excludePoiCategories=Restaurant,Cafe.
	//
	// See PoiCategory for a complete list of possible values.
	ExcludePoiCategories []PoiCategory `query:"excludePoiCategories"`

	// A comma-separated list of strings that describes the points of interest
	// to include in the search results.
	// For example, includePoiCategories=Restaurant,Cafe.
	//
	// See PoiCategory for a complete list of possible values.
	IncludePoiCategories []PoiCategory `query:"includePoiCategories"`

	// A comma-separated list of two-letter ISO 3166-1 codes of the countries to
	// limit the results to.
	// For example, limitToCountries=US,CA limits the search to the United
	// States and Canada.
	//
	// If you specify two or more countries, the results reflect the best
	// available results for some or all of the countries rather than everything
	// related to the query for those countries.
	LimitToCountries []countries.CountryCode `query:"limitToCountries,omitempty"`

	// A comma-separated list of strings that describes the kind of result types
	// to include in the response. For example, resultTypeFilter=Poi.
	//
	// Possible Values: Address, Poi, Query
	ResultTypeFilter []string `query:"resultTypeFilter"`

	// The language the server should use when returning the response, specified
	// using a BCP 47 language code.
	// For example, for English use lang=en-US. Defaults to en-US.
	//
	// Default: en-US
	Lang language.Tag `query:"lang"`

	// A location defined by the application as a hint. Specify the location as
	// a comma-separated string containing the latitude and longitude.
	// For example, searchLocation=37.78,-122.42.
	SearchLocation Location `query:"searchLocation"`

	// A region the app defines as a hint. Specify the region specified as a
	// comma-separated string that describes the region in the form
	// north-latitude,east-longitude,south-latitude,west-longitude.
	// For example, searchRegion=38,-122.1,37.5,-122.5.
	SearchRegion Region `query:"searchRegion"`

	// The location of the user, specified as a comma-separated string that
	// contains the latitude and longitude.
	// For example, userLocation=37.78,-122.42.
	// Search may opt to use the userLocation, if specified, as a fallback for
	// the searchLocation.
	UserLocation Location `query:"userLocation"`
}

func (*SearchAutoCompleteRequest) URLValues

func (req *SearchAutoCompleteRequest) URLValues() (url.Values, error)

func (*SearchAutoCompleteRequest) Validate

func (req *SearchAutoCompleteRequest) Validate() error

type SearchRequest

type SearchRequest struct {
	// (Required) The place to search for. For example, q=eiffel tower.
	Query string `query:"q" vd:"$!=''"`

	// A comma-separated list of strings that describes the points of interest
	// to exclude from the search results.
	// For example, excludePoiCategories=Restaurant,Cafe.
	//
	// See PoiCategory for a complete list of possible values.
	ExcludePoiCategories []PoiCategory `query:"excludePoiCategories"`

	// A comma-separated list of strings that describes the points of interest
	// to include in the search results.
	// For example, includePoiCategories=Restaurant,Cafe.
	//
	// See PoiCategory for a complete list of possible values.
	IncludePoiCategories []PoiCategory `query:"includePoiCategories"`

	// A comma-separated list of two-letter ISO 3166-1 codes of the countries to
	// limit the results to.
	// For example, limitToCountries=US,CA limits the search to the United
	// States and Canada.
	//
	// If you specify two or more countries, the results reflect the best
	// available results for some or all of the countries rather than everything
	// related to the query for those countries.
	LimitToCountries []countries.CountryCode `query:"limitToCountries,omitempty"`

	// A comma-separated list of strings that describes the kind of result types
	// to include in the response. For example, resultTypeFilter=Poi.
	//
	// Possible Values: Poi, Address
	ResultTypeFilter []string `query:"resultTypeFilter"`

	// The language the server should use when returning the response, specified
	// using a BCP 47 language code.
	// For example, for English use lang=en-US. Defaults to en-US.
	//
	// Default: en-US
	Lang language.Tag `query:"lang"`

	// A location defined by the application as a hint. Specify the location as
	// a comma-separated string containing the latitude and longitude.
	// For example, searchLocation=37.78,-122.42.
	SearchLocation Location `query:"searchLocation"`

	// A region the app defines as a hint. Specify the region specified as a
	// comma-separated string that describes the region in the form
	// north-latitude,east-longitude,south-latitude,west-longitude.
	// For example, searchRegion=38,-122.1,37.5,-122.5.
	SearchRegion Region `query:"searchRegion"`

	// The location of the user, specified as a comma-separated string that
	// contains the latitude and longitude.
	// For example, userLocation=37.78,-122.42.
	// Search may opt to use the userLocation, if specified, as a fallback for
	// the searchLocation.
	UserLocation Location `query:"userLocation"`
}

func (*SearchRequest) URLValues

func (req *SearchRequest) URLValues() (url.Values, error)

func (*SearchRequest) Validate

func (req *SearchRequest) Validate() error

type SearchResponse

type SearchResponse struct {
	DisplayMapRegion MapRegion `json:"displayMapRegion"`
	Results          []Place   `json:"results"`
}

type StructuredAddress

type StructuredAddress struct {
	AdministrativeArea     string   `json:"administrativeArea"`     // The state or province of the place.
	AdministrativeAreaCode string   `json:"administrativeAreaCode"` // The short code for the state or area.
	AreasOfInterest        []string `json:"areasOfInterest"`        // Common names of the area in which the place resides.
	DependentLocalities    []string `json:"dependentLocalities"`    // Common names for the local area or neighborhood of the place.
	FullThoroughfare       string   `json:"fullThoroughfare"`       // A combination of thoroughfare and subthoroughfare.
	Locality               string   `json:"locality"`               // The city of the place.
	PostCode               string   `json:"postCode"`               // The postal code of the place.
	SubLocality            string   `json:"subLocality"`            // The name of the area within the locality.
	SubThoroughfare        string   `json:"subThoroughfare"`        // The number on the street at the place.
	Thoroughfare           string   `json:"thoroughfare"`           // The street name at the place.
}

StructuredAddress is 'An object that describes the detailed address components of a place.'

type TransportType

type TransportType string

The mode of transportation the server returns directions for.

const (
	TransportTypeAutomobile TransportType = "Automobile"
	TransportTypeWalking    TransportType = "Walking"
)

Directories

Path Synopsis
_examples
Package mockclient is a generated GoMock package.
Package mockclient is a generated GoMock package.

Jump to

Keyboard shortcuts

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