maps

package module
v0.0.0-...-9d0e437 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2015 License: Apache-2.0 Imports: 15 Imported by: 0

README

GoDoc

Documentation

Index

Constants

View Source
const (
	// AvoidTolls indicates that the route should avoid toll roads.
	AvoidTolls = "tolls"
	// AvoidHighways indicates that the route should avoid highways.
	AvoidHighways = "highways"
	// AvoidFerries indicates that the route should avoid ferries.
	AvoidFerries = "ferries"

	// ModeDriving indicates that driving directions are requested.
	ModeDriving = "driving"
	// ModeWalking indicates that walking directions are requested.
	ModeWalking = "walking"
	// ModeTransit indicates that transit directions are requested.
	ModeTransit = "transit"
	// ModeBicycling indicates that bicycling directions are requested.
	ModeBicycling = "bicycling"

	// UnitMetric indicates that the results should be stated in metric units.
	UnitMetric = "metric"
	// UnitImperial indicates that the results should be stated in imperial units.
	UnitImperial = "imperial"
)
View Source
const (
	// ComponentRoute matches long or short name of a route.
	ComponentRoute = "route"
	// ComponentLocality matches against most locality and sublocality types.
	ComponentLocality = "locality"
	// ComponentAdministrativeArea matches all the administrative area levels.
	ComponentAdministrativeArea = "administrative_area"
	// ComponentPostalCode matches postcal code and postal code prefix.
	ComponentPostalCode = "postal_code"
	// ComponentCountry matches a country name or a two-letter ISO 3166-1 country code.
	ComponentCountry = "country"

	// LocationTypeRooftop restricts the results to addresses for which we have location information accurate down to street address precision.
	LocationTypeRooftop = "ROOFTOP"
	// LocationTypeRangeInterpolated restricts the results to those that reflect an approximation (usually a road) interpolated between two precise points (such as intersections).
	LocationTypeRangeInterpolated = "RANGE_INTERPOLATED"
	// LocationTypeGeometricCenter restricts the results to geometric centers of a location such as a polyline (for example, a street) or polygon (region).
	LocationTypeGeometricCenter = "GEOMETRIC_CENTER"
	// LocationTypeApproximate restricts the results to those that are characterized as approximate.
	LocationTypeApproximate = "APPROXIMATE"
)
View Source
const (

	// StatusOK indicates the response contains a valid result.
	StatusOK = "OK"
	// StatusNotFound indicates at least one of the locations specified could not be geocoded.
	StatusNotFound = "NOT_FOUND"
	// StatusZeroResults indicates no route could be found between the origin and destination.
	StatusZeroResults = "ZERO_RESULTS"
	// StatusMaxWaypointsExceeded indicates that too many Waypoints were provided in the request.
	//
	// The maximum allowed waypoints is 8, plus the origin and destination. Google Maps API for Work clients may contain requests with up to 23 waypoints.
	StatusMaxWaypointsExceeded = "MAX_WAYPOINTS_EXCEEDED"
	// StatusInvalidRequest indicates that the provided request was invalid.
	StatusInvalidRequest = "INVALID_REQUEST"
	// StatusRequestDenied indicates that the service denied use of the service by your application.
	StatusRequestDenied = "REQUEST_DENIED"
	// StatusUnknownError indicates that the request could not be processed due to a server error. The request may succeed if you try again.
	StatusUnknownError = "UNKNOWN_ERROR"
	// StatusOverQueryLimit indicates that the service has received too many requests from your application within the allowed time period.
	StatusOverQueryLimit = "OVER_QUERY_LIMIT"
)
View Source
const (
	// MapFormatPNG requests the image in PNG format.
	MapFormatPNG = "png"
	// MapFormatPNG32 requests the image in PNG32 format.
	MapFormatPNG32 = "png32"
	// MapFormatGIF requests the image in GIF format.
	MapFormatGIF = "gif"
	// MapFormatJPG requests the image in JPG format.
	MapFormatJPG = "jpg"
	// MapFormatJPGBaseline requests the image in a non-progressive JPG format.
	MapFormatJPGBaseline = "jpg-baseline"

	// MapTypeRoadmap requests a standard roadmap image.
	MapTypeRoadmap = "roadmap"
	// MapTypeSatellite requests a satellite image.
	MapTypeSatellite = "satellite"
	// MapTypeTerrain requests a terrain image.
	MapTypeTerrain = "terrain"
	// MapTypeHybrid requests a hybrid of the satellite and roadmap image.
	MapTypeHybrid = "hybrid"

	// SizeTiny requests a small-sized marker.
	SizeTiny = "tiny"
	// SizeMid requests a mid-sized marker.
	SizeMid = "mid"
	// SizeLarge requests a large-sized marker.
	SizeLarge = "large"

	// VisibilityOn requests that the feature be shown.
	VisibilityOn = "on"
	// VisibilityOff requests that the feature not be shown.
	VisibilityOff = "off"
	// VisibilitySimplified requests that the feature be shown in a simplified manner.
	VisibilitySimplified = "simplified"
)

Variables

View Source
var ErrNoAPIKey = errors.New("must provide an API key")

Functions

func Float64

func Float64(f float64) *float64

Float64 returns a pointer to the given float64 value.

This is a convenience method since some options structs take a *float64.

func NewContext

func NewContext(key string, c *http.Client) context.Context

NewContext returns a new context that uses the provided http.Client and API key.

func NewWorkContext

func NewWorkContext(clientID, privateKey string, c *http.Client) context.Context

NewWorkContext returns a new context that uses the provided http.Client and Google Maps API for Work client ID and private key.

func StaticMap

func StaticMap(ctx context.Context, s Size, opts *StaticMapOpts) (io.ReadCloser, error)

StaticMap requests a static map image of a requested size.

func StreetView

func StreetView(ctx context.Context, s Size, opts *StreetViewOpts) (io.ReadCloser, error)

StreetView requests a static StreetView image of the requested size.

func WithContext

func WithContext(parent context.Context, key string, c *http.Client) context.Context

WithContext returns a new context in a similar way NewContext does, but initiates the new context with the specified parent.

func WithWorkCredentials

func WithWorkCredentials(parent context.Context, clientID, privateKey string, c *http.Client) context.Context

WithWorkCredentials returns a new context in a similar way NewWorkContext does, but initiates the new context with the specified parent.

Types

type APIError

type APIError struct {
	Status, Message string
}

APIError indicates a failure response from the API server, even though a successful HTTP response was returned. Its Status and Message fields can be consulted for more information about the specific error conditions.

func (APIError) Error

func (e APIError) Error() string

type Address

type Address string

Address represents a Location that is identified by its name or address, e.g., "New York, NY" or "111 8th Ave, NYC"

func (Address) Location

func (a Address) Location() string

Location returns the Address as a string.

type Bounds

type Bounds struct {
	// The northeasternmost point of the bounding box.
	Northeast LatLng `json:"northeast"`

	// The southwesternmost point of the bounding box.
	Southwest LatLng `json:"southwest"`
}

Bounds describes a viewport bounding box.

func (Bounds) String

func (b Bounds) String() string

type Component

type Component struct {
	// Key is the type of component to filter on.
	//
	// Accepted values are ComponentRoute, ComponentLocality, ComponentAdministrativeArea, ComponentPostalCode and ComponentCountry.
	Key string

	// Value is the value of the filter to enforce.
	Value string
}

Component describes a single component filter.

See https://developers.google.com/maps/documentation/geocoding/#ComponentFiltering

type DirectionsOpts

type DirectionsOpts struct {
	// Waypoints alter a route by routing it through the specified location(s).
	//
	// Waypoints are only supported for driving, walking and bicycling directions.
	//
	// See https://developers.google.com/maps/documentation/directions/#Waypoints
	Waypoints []Location

	// If true and if waypoints are specified, the Directions API may optimize the provided route by rearranging the waypoints in a more efficient order.
	OptimizeWaypoints bool

	// If true, multiple Routes may be returned. This may increase the response time from the server.
	Alternatives bool

	// Avoid indicates that the calculated route(s) should avoid the indicated features.
	//
	// Accepted values are AvoidTolls, AvoidHighways and AvoidFerries
	//
	// See https://developers.google.com/maps/documentation/directions/#Restrictions
	Avoid []string

	// Specifies the mode of transport to use when calculating directions.
	//
	// Accepted values are ModeDriving (the default), ModeWalking, ModeTransit and ModeBicycling.
	// If ModeTransit is specified, either DepartureTime or ArrivalTime must also be specified.
	//
	// See https://developers.google.com/maps/documentation/directions/#TravelModes
	Mode string

	// The language in which to return results.
	//
	// See https://developers.google.com/maps/faq#languagesupport
	Language string

	// Specifies the unit system to use when displaying results.
	//
	// Accepted values are UnitMetric and UnitImperial.
	//
	// See https://developers.google.com/maps/documentation/directions/#UnitSystems
	Units string

	// The region code, specified as a ccTLD ("top-level domain") two-character value.
	//
	// See https://developers.google.com/maps/documentation/directions/#RegionBiasing
	Region string

	// Specifies the desired time of departure.
	//
	// The departure time can be specified for transit directions, or for Google Maps API for Work
	// clients to receive trip duration considering current traffic conditions.
	DepartureTime time.Time

	// Specifies the desired time of arrival for transit directions.
	ArrivalTime time.Time
}

DirectionsOpts defines options for Directions requests.

type Distance

type Distance struct {
	// Value is the distance in meters
	Value int64 `json:"value"`

	// Text contains a human-readable representation of the distance, displayed in the requested unit and language, or in the unit and language used at the origin.
	Text string `json:"text"`
}

Distance describes a distance for a leg or step.

type DistanceMatrixOpts

type DistanceMatrixOpts struct {
	// The language in which to return results.
	//
	// See https://developers.google.com/maps/faq#languagesupport
	Language string

	// Specifies the unit system to use when displaying results.
	//
	// Accepted values are UnitMetric and UnitImperial.
	//
	// See https://developers.google.com/maps/documentation/distancematrix/#unit_systems
	Units string

	// Specifies the mode of transport to use when calculating directions.
	//
	// Accepted values are ModeDriving (the default), ModeWalking and ModeBicycling.
	Mode string

	// Indicates that the calculated route(s) should avoid the indicated features.
	//
	// Accepted values are AvoidTolls, AvoidHighways or AvoidFerries
	//
	// See https://developers.google.com/maps/documentation/distancematrix/#Restrictions
	Avoid string

	// Specifies the desired time of departure.
	//
	// The departure time can be specified for Google Maps API for Work clients to receive trip duration considering current traffic conditions.
	DepartureTime time.Time
}

DistanceMatrixOpts defines options for DistanceMatrix requsts.

type DistanceMatrixResult

type DistanceMatrixResult struct {
	// OriginAddresses contains the addresses returned by the API from your original request.
	//
	// These are formatted by the geocoder and localized according to the requested Language.
	OriginAddresses []string `json:"origin_addresses"`

	// DestinationAddresses contains the addresses returned by the API from your original request.
	//
	// These are formatted by the geocoder and localized according to the requested Language.
	DestinationAddresses []string `json:"destination_addresses"`

	// Rows describes rows in the matrix.
	Rows []struct {
		// Elements describes columns in the matrix.
		Elements []struct {
			// Status indicates the status of the request, and will be one of StatusOK, StatusNotFound or StatusZeroResults.
			Status string `json:"status"`

			// Duration indicates the total duration of this journey.
			Duration Duration `json:"duration"`

			// Distance indicates the total distance of this journey.
			Distance Distance `json:"distance"`
		} `json:"elements"`
	} `json:"rows"`
}

DistanceMatrixResult describes the matrix of distances between the requested origins and destinations.

func DistanceMatrix

func DistanceMatrix(ctx context.Context, orig, dest []Location, opts *DistanceMatrixOpts) (*DistanceMatrixResult, error)

DistanceMatrix requests travel distance and time for a matrix of origins and destinations.

See https://developers.google.com/maps/documentation/distancematrix/

type Duration

type Duration struct {
	// Value indicates the duration in seconds.
	Value int64 `json:"value"`

	// Text contains a human-readable representation of the duration.
	Text string `json:"text"`
}

Duration describes an amount of time for a leg or step.

func (Duration) Duration

func (d Duration) Duration() time.Duration

Duration translates the Duration into a time.Duration.

type ElevationResult

type ElevationResult struct {
	// Elevation is elevation of the location in meters.
	Elevation float64 `json:"elevation"`

	// Location is the location of the location being described.
	Location LatLng `json:"location"`

	// Resolution is the maximum distance between data points from which the elevation was interpolated, in meters.
	//
	// This property will be zero if the resolution is not known. Note that elevation data becomes
	// more coarse (larger Resolution values) when multiple points are passed. To obtain the most
	// accurate elevation value for a point, it should be queried independently.
	Resolution float64 `json:"resolution"`
}

ElevationResult describes elevation data.

func Elevation

func Elevation(ctx context.Context, ll []LatLng) ([]ElevationResult, error)

Elevation requests elevation data for a series of locations.

See https://developers.google.com/maps/documentation/elevation/

func ElevationPath

func ElevationPath(ctx context.Context, ll []LatLng, samples int) ([]ElevationResult, error)

ElevationPath requests elevation data for a number of samples along a path described as a series of locations.

func ElevationPathPoly

func ElevationPathPoly(ctx context.Context, p string, samples int) ([]ElevationResult, error)

ElevationPathPoly requests elevation data for a number of samples along a path described as a series of locations specified as an encoded polyline.

func ElevationPolyline

func ElevationPolyline(ctx context.Context, p string) ([]ElevationResult, error)

ElevationPolyline requests elevation data for a series of locations as specified as an encoded polyline.

See https://developers.google.com/maps/documentation/elevation/#Locations

type GeocodeOpts

type GeocodeOpts struct {
	// The address to geocode.
	Address Address

	// Components specifies a component filter for which you wish to obtain a geocode.
	//
	// Only results that match all filters will be returned. Filter values support the same methods of spelling correction and partial matching as other geocoding requests.
	//
	// See https://developers.google.com/maps/documentation/geocoding/#ComponentFiltering
	Components []Component

	// The language in which to return results.
	//
	// See https://developers.google.com/maps/faq#languagesupport
	Language string

	// Region specifies a region to bias results toward, specified as a ccTLD ("top-level domain" two-character value.
	//
	// This will influence, not fully restrict, results from the geocoder.
	//
	// See https://developers.google.com/maps/documentation/geocoding/#RegionCodes
	Region string

	// Bounds specifies the bounding box of the viewport within which to bias geocode results more prominently.
	//
	// This will influence, not fully restrict, results from the geocoder.
	Bounds *Bounds
}

GeocodeOpts defines options for Geocode requests.

type GeocodeResult

type GeocodeResult struct {
	// AddressComponents contains the separate address components.
	AddressComponents []struct {
		// LongName is the full text description or name of the address component returned by the geocoder.
		LongName string `json:"long_name"`
		// ShortName is the abbreviated textual name for the address component, if available.
		//
		// For example, an address component for the state of Alaska may have a LongName of "Alaska" and a ShortName of "AK" using the 2-letter postal abbreviation.
		ShortName string `json:"short_name"`

		// Types contains the types of address components.
		Types []string `json:"types"`
	} `json:"address_components"`

	// PostcodeLocalities denotes all the localities contained in a postal code.
	//
	// This is only present when the result is a postal code that contains multiple localities.
	PostcodeLocalities []string `json:"postcode_localities"`

	// FormattedAddress contains the human-readable address of this location.
	//
	// Often this is equivalent to the "postal address" which sometimes differs from country to country.
	FormattedAddress string `json:"formatted_address"`

	// Geometry contains information about the location.
	Geometry struct {
		// Location is the geocoded latitude and longitude of the location.
		Location LatLng `json:"location"`

		// LocationType specifies additional data about the specified location.
		//
		// Its value will be one of:
		// - "ROOFTOP" indicating that the returned result is a precise geocode for which we have location information accurate down to street address precision.
		// - "RANGE_INTERPOLATED" indicating that the returned result reflects and approximation (usually on a road) interpolated between two precise points (such as intersections). Interpolated results are generally returned when rooftop geocodes are unavailable for a street address.
		// - "GEOMETRIC_CENTER" indicating that the returned result is the geometric center of a result such as a polyline (for example, a street) or polygon (region).
		LocationType string `json:"location_type"`

		// Viewport contains the recommended viewport bounding box for displaying the returned result.
		Viewport Bounds `json:"viewport"`

		// Bounds, if included, contains the bounding box which can fully contain the returned result.
		//
		// Note that this may not match Viewport.
		Bounds Bounds `json:"bounds"`
	} `json:"geometry"`

	// Types indicates the types of the returned result.
	//
	// This contains a set of zero or more tags identifying the type of feature returned in a result.
	// For example, a geocode of "Chicago" returns "locality" which indicates that "Chicago" is a city,
	// and also returns "political" which indicates it is a political entity.
	Types []string `json:"types"`

	// PartialMatch indicates that the geocoder did not return an exact match for the original request,
	// though it was able to match part of the requested address. You may wish to examine the original
	// request for misspellings and/or an incomplete address.
	PartialMatch string `json:"partial_match"`
}

GeocodeResult represents the geocoded result for the given input.

func Geocode

func Geocode(ctx context.Context, opts *GeocodeOpts) ([]GeocodeResult, error)

Geocode requests conversion of an address to a latitude/longitude pair.

func ReverseGeocode

func ReverseGeocode(ctx context.Context, ll LatLng, opts *ReverseGeocodeOpts) ([]GeocodeResult, error)

ReverseGeocode requests conversion of a location to its nearest address.

See https://developers.google.com/maps/documentation/geocoding/#ReverseGeocoding

type HTTPError

type HTTPError struct {
	// Response is the http.Response returned from the API request.
	Response *http.Response
}

HTTPError indicates an error communicating with the API server, and includes the HTTP response returned from the server.

func (HTTPError) Error

func (e HTTPError) Error() string

type LatLng

type LatLng struct {
	Lat float64 `json:"lat"`
	Lng float64 `json:"lng"`
}

LatLng represents a Location that is identified by its longitude and latitude.

func (LatLng) Location

func (ll LatLng) Location() string

Location returns the latitude/longitude pair as a comma-separated string.

func (LatLng) String

func (ll LatLng) String() string

type Location

type Location interface {
	Location() string
}

Location represents the general concept of a location in various methods.

type Markers

type Markers struct {
	// Size defines the size of the marker(s).
	//
	// Accepted values are SizeTiny, SizeMid (the default) and SizeLarge.
	Size string // tiny, mid, small

	// Color defines the color of the marker(s).
	//
	// The alpha value of this color is ignored.
	Color color.Color

	// Label specifies a single uppercase alphanumeric character to place inside the marker image.
	Label string

	// IconURL specifies the URL of a custom icon image to use.
	IconURL string

	// HideShadow, if true, will not include a shadow for the marker(s).
	HideShadow bool

	// Locations specifies the locations of markers to be placed in this group.
	Locations []Location
}

Markers defines marker(s) to attach to the image.

type Path

type Path struct {
	// Weight specifies the thickness of the path in pixels. If no weight is specified, the default is 5 pixels.
	Weight int

	// Color defines the color of the path.
	Color color.Color

	// FillColor defines the color to fill the area of the path.
	FillColor color.Color

	// Geodesic, if true, indicates that the requested path should be interpreted as a geodesic line that follows the curvature of the earth.
	//
	// If false (the default), the path is rendered as a straight line in screen space.
	Geodesic bool

	// Polyline specifies an encoded polyline of points defining the path, if Locations is not provided.
	Polyline string

	// Locations specifies the points of the path.
	Locations []Location
}

Path defines a path to attach to the image at specified locations.

type Polyline

type Polyline struct {
	// Points is an encoded polyline describing some path.
	//
	// See https://developers.google.com/maps/documentation/utilities/polylinealgorithm
	Points string `json:"points"`
}

Polyline contains data describing an encoded polyline.

type ReverseGeocodeOpts

type ReverseGeocodeOpts struct {
	// The language in which to return results.
	//
	// See https://developers.google.com/maps/faq#languagesupport
	Language string

	// ResultTypes specifies filters on result types, e.g., "country", "street address"
	ResultTypes []string

	// LocationTypes specifies filters on location types.
	//
	// Accepted values are LocationTypeRooftop, LocationTypeRangeInterpolated, LocationTypeGeometricCenter and LocationTypeApproximate.
	LocationTypes []string
}

ReverseGeocodeOpts defines options for ReverseGeocode requests.

type Route

type Route struct {
	// Summary contains a short textual description of the route, suitable for naming and disambiguating the route from alternatives.
	Summary string `json:"summary"`

	// Legs contains information about the legs of a route, between two locations within the route.
	// A separate leg will be present for each waypoint or destination specified. If no waypoints were
	// requested, this will contain one element.
	//
	// See https://developers.google.com/maps/documentation/directions/#Legs
	Legs []struct {
		// Duration indicates the total duration of this leg.
		Duration *Duration `json:"duration"`

		// DurationInTraffic indicates the total duration of this leg, taking into account current traffic conditions.
		//
		// It will only be included if all of the following are true:
		// - The directions request includes a DepartureTime parameter set to a value within a few minutes of the current time.
		// - The request is made using a Google Maps API for Work client.
		// - Traffic conditions are available for the requested route.
		// - The directions request doesnot include stopover waypoints.
		DurationInTraffic *Duration `json:"duration_in_traffic"`

		// Distance is the total distance covered by this leg.
		Distance *Distance `json:"distance"`

		// ArrivalTime indicates the estimated time of arrival for this leg. This is only included for transit directions.
		ArrivalTime Time `json:"arrival_time"`

		// DepartureTime indicates the estimated time of arrival for this leg. This is only included for transit directions.
		DepartureTime Time `json:"departure_time"`

		// StartLocation indicates the origin of this leg.
		//
		// Because the Directions API calculates directions between locations by using the nearest transportation option (usually a road)
		// at the start and end points, StartLocation may be different than the provided origin of this leg if, for example, a road is not near the origin.
		StartLocation *LatLng `json:"start_location"`

		// EndLocation indicates the destination of this leg.
		//
		// Because the Directions API calculates directions between locations by using the nearest transportation option (usually a road)
		// at the start and end points, EndLocation may be different than the provided destination of this leg if, for example, a road is not near the destination.
		EndLocation *LatLng `json:"end_location"`

		// StartAddress contains the human-readable address (typically a street address) reflecting the StartLocation of this leg.
		StartAddress string `json:"start_address"`

		// EndAddress contains the human-readable address (typically a street address) reflecting the EndLocation of this leg.
		EndAddress string `json:"end_address"`

		// Steps describes each step of the leg of the journey.
		//
		// See https://developers.google.com/maps/documentation/directions/#Steps
		Steps []Step `json:"steps"`
	} `json:"legs"`

	// Bounds describes the viewport bounding box of the OverviewPolyline
	Bounds Bounds `json:"bounds"`

	// Copyrights contains the copyright text to be displayed for this route. You must display this information yourself.
	Copyrights string `json:"copyrights"`

	// OverviewPolyline contains the encoded polyline representation of the route. This polyline is an approximate (smoothed) path of the resulting directions.
	OverviewPolyline Polyline `json:"overview_polyline"`

	// Warnings contains any warnings to display to the user when showing these directions. You must display these warnings yourself.
	Warnings []string `json:"warnings"`

	// WaypointOrder indicates the order of any waypoints in the calculated route. The waypoints may be reordered if OptimizeWaypoints was specified.
	WaypointOrder []int `json:"waypoint_order"`
}

Route describes a possible route between the requested origin and destination.

func Directions

func Directions(ctx context.Context, orig, dest Location, opts *DirectionsOpts) ([]Route, error)

Directions requests routes between orig and dest Locations.

See https://developers.google.com/maps/documentation/directions/

type Size

type Size struct {
	H, W int
}

Size specifies the height and width of the image to request in pixels.

See https://developers.google.com/maps/documentation/staticmaps/#Imagesizes

func (Size) String

func (s Size) String() string

type SnapToRoadsOpts

type SnapToRoadsOpts struct {
	// Whether to interpolate a path to include all points forming the full road-geometry.
	Interpolate bool
}

SnapToRoadsOpts defines options for SnapToRoads requests.

type SnappedLocation

type SnappedLocation struct {
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
}

SnappedLocation is equivalent to LatLng

TODO(jasonhall): Reconcile this with LatLng which expects JSON fields lat/lng

type SnappedPoint

type SnappedPoint struct {
	// The latitude and longitude of the snapped location.
	Location SnappedLocation `json:"location"`

	// The index of the corresponding value in the original request.
	//
	// Each value in the request should map to a snapped value in the response. However, if you've set Interpolate to be true, then it's possible that the response will contain more coordinates than the request. Interpolated values will have this value set to nil.
	OriginalIndex *int `json:"originalIndex,omitempty"`

	// A unique identifier for a Place corresponding to a road segment.
	PlaceID string `json:"placeId"`
}

SnappedPoint represents a location derived from a SnapToRoads request.

func SnapToRoads

func SnapToRoads(ctx context.Context, path []LatLng, opts *SnapToRoadsOpts) ([]SnappedPoint, error)

type StaticMapOpts

type StaticMapOpts struct {
	// Center specifies the location to place at the center of the image.
	Center Location

	// Zoom is the zoom level to request.
	//
	// The zoom level is between 0 (the lowest level, in which the entire world can be seen on one map)
	// and 21+ (down to streets and individual buildings).
	//
	// Each zoom level doubles the precision in both horizontal and vertical dimensions.
	//
	// See https://developers.google.com/maps/documentation/staticmaps/#Zoomlevels
	Zoom int

	// Scale requests a higher-resolution map image for use on high-density displays.
	//
	// A scale value of 2 will double the resulting image size. A scale value of 4 (only available to Google Maps API for Work clients) will quadruple it.
	Scale int

	// Format specifies the image format to request.
	//
	// Accepted values are MapFormatPNG (the default), MapFormatPNG32, MapFormatGIF, MapFormatJPG and MapFormatJPGBaseline.
	Format string

	// MapType specifies the map type to request.
	//
	// Accepted values are MapTypeRoadmap (the default), MapTypeSatellite, MapTypeTerrain and MapTypeHybrid.
	MapType string

	// The language in which to localize labels on the map.
	//
	// See https://developers.google.com/maps/faq#languagesupport
	Language string

	// Region defines the appropriate borders to display, based on geo-political sensitivities.
	//
	// Accepts a two-character ccTLD ("top-level domain") value.
	Region string

	// Markers defines one or more markers to attach to the image at specified locations.
	//
	// See https://developers.google.com/maps/documentation/staticmaps/#Markers
	Markers []Markers

	// Path defines one or more paths to attach to the image at specified locations.
	//
	// See https://developers.google.com/maps/documentation/staticmaps/#Paths
	Paths []Path

	// Visible specifies one or more locations that should remain visible on the map, though no markers or other indicators will be displayed.
	Visible []Location

	// Styles defines custom styles to alter the presentation of specific features on the map.
	//
	// See https://developers.google.com/maps/documentation/staticmaps/#StyledMaps
	Styles []Style
}

StaticMapOpts defines options for StaticMap requests.

type Step

type Step struct {
	TravelMode string `json:"travel_mode"` // TODO: not documented? (all caps)

	// StartLocation contains the location of the starting point of this step.
	StartLocation *LatLng `json:"start_location"`

	// EndLocation contains the location of the ending point of this step.
	EndLocation *LatLng `json:"end_location"`

	Maneuver string `json:"maneuver"` // TODO: not documented?

	// Contains an encoded polyline representation of the step. This is an approximate (smoothed) path of the step.
	Polyline *Polyline `json:"polyline"`

	// Duration indicates the total duration of this step.
	Duration *Duration `json:"duration"`

	// Distance is the total distance covered by this step.
	Distance *Distance `json:"distance"`

	// HTMLInstructions contains formatted instructions for this step, presented as an HTML text string.
	HTMLInstructions string `json:"html_instructions"`

	// Steps contains detailed directions for walking or driving steps in transit directions. These are only available when the requested Mode is ModeTransit
	Steps []Step `json:"steps"`

	// TransitDetails contains transit-specific information. This is only included when the requested Mode is ModeTransit
	//
	// See https://developers.google.com/maps/documentation/directions/#TransitDetails
	TransitDetails *struct {
		// ArrivalStop contains information about the arrival stop for this part of the trip.
		ArrivalStop Stop `json:"arrival_stop"`

		// DepartureStop contains information about the departure stop for this part of the trip.
		DepartureStop Stop `json:"departure_stop"`

		// ArrivalTime indicates the arrival time for this leg of the journey.
		ArrivalTime Time `json:"arrival_time"`

		// DepartureTime indicates the departure time for this leg of the journey.
		DepartureTime Time `json:"departure_time"`

		// Headsign specifies the direction in which to travel on this line, as it is marked on the vehicle or at the departure stop. This will often be the terminus station.
		Headsign string `json:"headsign"`

		// Headway specifies the expected number of seconds between departure from the same stop at this time.
		//
		// For example, with a Headway of 600, you would expect a ten minute way if you should miss your bus.
		Headway int64 `json:"headway"` // TODO: to time.Duration?

		// NumStops indicates the number of stops in this step, counting the arrival stop, but not the departure stop.
		//
		// For example, if your directions involve leaving Stop A, passing through Stops B and C, and arriving at Stop D, NumStops will be 3.
		NumStops int `json:"num_stops"`

		// Line contains information about the transit line used in this step.
		Line struct {
			// Name is the full name of this transit line, e.g., "7 Avenue Express"
			Name string `json:"name"`

			// ShortName is the short name of this transit line. This will normally be a line number, such as "M7" or "355"
			ShortName string `json:"short_name"`

			// Color is the color commonly used in signage for this transit line, specified as a hex string such as "#FF0033"
			Color string `json:"color"` // TODO: to image.Color?

			// Agencies contains information about the operator of the line.
			//
			// You must display the names and URLs of the transit agencies servicing the trip results.
			Agencies []struct {
				// Name is the name of the transit agency.
				Name string `json:"name"`

				// URL is the URL for the transit agency.
				URL string `json:"url"`

				// Phone is the phone number of the transit agency.
				Phone string `json:"phone"`
			} `json:"agencies"`

			// URL is the URL for this transit line as provided by the transit agency.
			URL string `json:"url"`

			// IconURL is the URL for the icon associated with this line.
			IconURL string `json:"icon"`

			// TextColor is the color of text commonly used for signage of this line, specified as a hex string such as "#FF0033"
			TextColor string `json:"text_color"` // TODO: to image.Color?

			// Vehicle contains the type of vehicle used on this line.
			Vehicle *struct {
				// Name is the name of the vehicle used on this line, e.g., "Subway"
				Name string `json:"name"`

				// Type is the type of the vehicle that runs on this line.
				//
				// See https://developers.google.com/maps/documentation/directions/#VehicleType
				Type string `json:"type"`

				// IconURL is the URL for an icon associated with this vehicle type.
				IconURL string `json:"icon"`
			} `json:"vehicle"`
		} `json:"line"`
	} `json:"transit_details"`
}

Step describes a step of a leg of a journey.

See https://developers.google.com/maps/documentation/directions/#Steps

type Stop

type Stop struct {
	// Location is the location of the station/stop.
	Location LatLng `json:"location"`

	// Name is the name of the transit station/stop, e.g., "Union Square".
	Name string `json:"name"`
}

Stop describes a transit station or stop.

type StreetViewOpts

type StreetViewOpts struct {
	// Location specifies the location where the image should be snapped from.
	Location Location

	// Pano specifies a specific Panoramio ID.
	Pano string

	// Heading specifies the compass heading (between 0 and 360) of the camera.
	//
	// Both 0 and 360 indicate North, 90 indicates East, 180 indicates South, and so on.
	//
	// If no heading is specified, a value will be calculated that directs the camera towards the specified Location, from a point at which the closest photograph was taken.
	Heading *float64

	// FOV specifies the field of view of the image.
	//
	// Accepted values are between 0 and 120, and if no value is given, a field of view of 90 degrees will be used.
	FOV *float64

	// Pitch specifies the up or down angle of the camera relative to the Street View vehicle.
	//
	// This is often, but not always, flat horizontal. Positive values angle the camera up (90 degrees indicating straight up); negative values angle the camera down (-90 indicates straight down).
	Pitch float64
}

StreetViewOpts defines options for StreetView requests.

type Style

type Style struct {
	// Feature specifies the feature type for this style modification.
	//
	// See https://developers.google.com/maps/documentation/staticmaps/#StyledMapFeatures
	Feature string // TODO enum

	// Element indicates the subset of selected features to style.
	//
	// See https://developers.google.com/maps/documentation/staticmaps/#StyledMapElements
	Element string // TODO enum

	// Rules specifies the style rules to apply to the map.
	Rules []StyleRule
}

Style defines a set of rules to use to style the requested map image.

type StyleRule

type StyleRule struct {
	// Hue is the hue value to apply to the selection.
	//
	// Note that while this takes a color value, it only uses this value to determine the basic color (its orientation around the color wheel),
	// not its saturation or lightness, which are indicated separately as percentage changes.
	Hue color.Color

	// Lightness (a value between -100 and 100) indicates the percentage change in brightness of the element. -100 is black, 100 is white.
	Lightness float64

	// Saturation (a value between -100 and 100) indicates the percentage change in intensity of the basic color to apply to the element.
	Saturation float64

	// Gamma (a value between 0.01 and 10.0, where 1.0 applies no correction) indicates the amount of gamma correction to apply to the element.
	Gamma *float64 // .01 to 10, default 1

	// InverseLightness, if true, inverts the Lightness value.
	InverseLightness bool

	// Visibility indicates whether and how the element appears on the map.
	//
	// Accepted values are VisibilityOn (the default), VisibilityOff and VisibilitySimplified.
	Visibility string
}

StyleRule defines a style rule to apply to the map.

type Time

type Time struct {
	// Value indicates the number of seconds since epoch of this time.
	Value int64 `json:"value"`

	// Text contains a human-readable time, displayed in the time zone of the transit stop.
	Text string `json:"text"`

	// TimeZone indicates the time zone of this station, e.g., "America/New_York"
	TimeZone string `json:"time_zone"`
}

Time represents a time.

func (Time) Time

func (t Time) Time() (*time.Time, error)

Time returns the Time as a time.Time, in the specified TimeZone.

type TimeZoneOpts

type TimeZoneOpts struct {
	// The language in which to return results.
	//
	// See https://developers.google.com/maps/faq#languagesupport
	Language string
}

TimeZoneOpts defines options for TimeZone requests.

type TimeZoneResult

type TimeZoneResult struct {
	// DSTOffset is the offset for daylight-savings time in seconds.
	//
	// This will be zero if the time zone is not in Daylight Savings Time during the specified time.
	DSTOffset int64 `json:"dstOffset"`

	// RawOffset is the offset from UTC (in seconds) for the given location.
	//
	// This does not take into effect daylight savings.
	RawOffset int64 `json:"rawOffset"`

	// TimeZoneID is a string containing the "tz" ID of the time zone, such as "America/Los_Angeles"
	TimeZoneID string `json:"timeZoneId"`

	// TimeZoneName is a string containing the long form name of the time zone, e.g., "Pacific Daylight Time".
	//
	// This field will be localized if the Language was specified.
	TimeZoneName string `json:"timeZoneName"`
}

TimeZoneResult describes information about the time zone at the requested location.

func TimeZone

func TimeZone(ctx context.Context, ll LatLng, t time.Time, opts *TimeZoneOpts) (*TimeZoneResult, error)

TimeZone requests time zone information about a location.

See https://developers.google.com/maps/documentation/timezone/

func (TimeZoneResult) DSTOffsetDuration

func (r TimeZoneResult) DSTOffsetDuration() time.Duration

DSTOffsetDuration translates the DSTOffset into a time.Duration

func (TimeZoneResult) RawOffsetDuration

func (r TimeZoneResult) RawOffsetDuration() time.Duration

RawOffsetDuration translates the RawOffset into a time.Duration

Jump to

Keyboard shortcuts

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