Documentation ¶
Overview ¶
Example (Client_LookupLatLon) ¶
package main import ( "context" "fmt" "log" "github.com/orijtech/mapbox" ) func main() { client, err := mapbox.NewClient() if err != nil { log.Fatal(err) } resp, err := client.LookupLatLon(context.Background(), 38.8971, -77.0366) if err != nil { log.Fatal(err) } for i, feat := range resp.Features { fmt.Printf("Match: #%d Name: %q Relevance: %v Center: %#v\n", i, feat.PlaceName, feat.Relevance, feat.Center) for j, ctx := range feat.Context { fmt.Printf("\tContext: #%d:: %#v\n", j, ctx) } fmt.Printf("\n\n") } }
Output:
Example (Client_LookupPlace) ¶
package main import ( "context" "fmt" "log" "github.com/orijtech/mapbox" ) func main() { client, err := mapbox.NewClient() if err != nil { log.Fatal(err) } // Time for some tacos, let's lookup that new spot. match, err := client.LookupPlace(context.Background(), "Tacquerias El Farolito") if err != nil { log.Fatal(err) } for i, feat := range match.Features { fmt.Printf("Match: #%d Name: %q Relevance: %v Center: %#v\n", i, feat.PlaceName, feat.Relevance, feat.Center) for j, ctx := range feat.Context { fmt.Printf("\tContext: #%d:: %#v\n", j, ctx) } fmt.Printf("\n\n") } }
Output:
Index ¶
- Variables
- type Client
- func (c *Client) APIKey() string
- func (c *Client) APIVersion() string
- func (c *Client) LookupLatLon(ctx context.Context, lat, lon float64) (*GeocodeResponse, error)
- func (c *Client) LookupPlace(ctx context.Context, query string) (*GeocodeResponse, error)
- func (c *Client) RequestDuration(ctx context.Context, dreq *DurationRequest) (*DurationResponse, error)
- func (c *Client) ReverseGeocoding(ctx context.Context, req *ReverseGeocodeRequest) (*GeocodeResponse, error)
- func (c *Client) SetAPIKey(key string)
- type DurationRequest
- type DurationResponse
- type GeocodeContext
- type GeocodeFeature
- type GeocodeMode
- type GeocodeProperty
- type GeocodeRequest
- type GeocodeResponse
- type GeocodeType
- type Geometry
- type LatLonMatrix
- type LatLonPair
- type Option
- type ReverseGeocodeRequest
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var NoPathDuration = float32(-1)
Functions ¶
This section is empty.
Types ¶
type Client ¶
func (*Client) APIVersion ¶
func (*Client) LookupLatLon ¶
LookupLatLon is a helper to reverse geocoding lookup a latitude and longitude pair.
func (*Client) LookupPlace ¶
LookupPlace looks up the coordinates and information of a place for example "Los Angeles" or "Edmonton".
func (*Client) RequestDuration ¶
func (c *Client) RequestDuration(ctx context.Context, dreq *DurationRequest) (*DurationResponse, error)
func (*Client) ReverseGeocoding ¶
func (c *Client) ReverseGeocoding(ctx context.Context, req *ReverseGeocodeRequest) (*GeocodeResponse, error)
ReverseGeocoding Converts coordinates to place names -77.036,38.897 -> 1600 Pennsylvania Ave NW.
type DurationRequest ¶
type DurationRequest struct {
Coordinates []*LatLonPair `json:"coordinates"`
}
type DurationResponse ¶
type DurationResponse struct {
Durations []*LatLonPair `json:"durations,omitempty"`
}
type GeocodeContext ¶
type GeocodeFeature ¶
type GeocodeFeature struct { Id string `json:"id"` Type string `json:"type"` Text string `json:"text"` PlaceName string `json:"place_name"` Relevance float32 `json:"relevance"` Properties *GeocodeProperty `json:"properties"` Context []*GeocodeContext `json:"context"` BoundingBox []float32 `json:"bbox"` Center []float32 `json:"center"` Geometry *Geometry `json:"geometry"` Attribution string `json:"attribution"` }
type GeocodeMode ¶
type GeocodeMode string
const ( GeocodePlaces GeocodeMode = "mapbox.places" GeocodePermanentPlaces GeocodeMode = "mapbox.places-permanent" )
func (GeocodeMode) String ¶
func (gm GeocodeMode) String() string
type GeocodeProperty ¶
type GeocodeProperty map[string]interface{}
type GeocodeRequest ¶
type GeocodeRequest struct { // Country is a set of one or more countries // specified with ISO 3166 alpha 2 country codes. Country []string `json:"country,omitempty"` Limit uint `json:"limit,omitempty"` Types []GeocodeType `json:"types,omitempty"` Proximity *LatLonPair `json:"proximity,omitempty"` BoundingBox []float32 `json:"bbox,omitempty"` AutoComplete bool `json:"autocomplete,omitempty"` }
type GeocodeResponse ¶
type GeocodeResponse struct { Type string `json:"type,omitempty"` Query *LatLonPair `json:"query,omitempty"` Features []*GeocodeFeature `json:"features,omitempty"` }
type GeocodeType ¶
type GeocodeType string
const ( GTypeRegion GeocodeType = "region" GTypePostcode GeocodeType = "postcode" GTypePlace GeocodeType = "place" GTypeLocality GeocodeType = "locality" GTypeNeighborhood GeocodeType = "neighborhood" GTypeAddress GeocodeType = "address" GTypePOI GeocodeType = "poi" GTypePOILandmark GeocodeType = "poi.landmark" )
type LatLonMatrix ¶
type LatLonMatrix [][]float32
type LatLonPair ¶
type LatLonPair []float32
func (*LatLonPair) UnmarshalJSON ¶
func (llp *LatLonPair) UnmarshalJSON(b []byte) error
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func WithHTTPClient ¶
type ReverseGeocodeRequest ¶
type ReverseGeocodeRequest struct { Query string `json:"query"` Mode GeocodeMode `json:"mode"` Request *GeocodeRequest }
Click to show internal directories.
Click to hide internal directories.