mapbox

package module
v0.2.1-0...-216ad52 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

README

mapbox-go

Go Client for Mapbox API

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	HttpClient HTTPClient
	// contains filtered or unexported fields
}

func NewClient

func NewClient(username, token string) *Client

func (*Client) GetStyle

func (c *Client) GetStyle(id string, draft bool) (Style, error)

func (*Client) GetTileJSON

func (c *Client) GetTileJSON(tilesetIDs ...string) (TileJSON, error)

func (*Client) ListStyles

func (c *Client) ListStyles(draft bool) ([]ListStyle, error)

func (*Client) ListTilesets

func (c *Client) ListTilesets(params ListTilesetsParams) ([]Tileset, error)

type HTTPClient

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

type Layer

type Layer struct {
	ID          string           `json:"id" binding:"required"`
	Type        string           `json:"type" binding:"required,oneof=fill line symbol circle heatmap fill-extrusion raster hillshade background sky"`
	Filter      *json.RawMessage `json:"filter,omitempty"`
	Layout      *json.RawMessage `json:"layout,omitempty"`
	MaxZoom     *float64         `json:"maxzoom,omitempty"`
	MinZoom     *float64         `json:"minzoom,omitempty"`
	Metadata    *json.RawMessage `json:"metadata,omitempty"`
	Paint       *json.RawMessage `json:"paint,omitempty"`
	Source      *string          `json:"source,omitempty"`
	SourceLayer string           `json:"source-layer,omitempty"`
}

type Light

type Light struct {
	Anchor    string  `json:"anchor,omitempty"`
	Color     string  `json:"color,omitempty"`
	Intensity float64 `json:"intensity,omitempty"`
}

https://docs.mapbox.com/mapbox-gl-js/style-spec/light/

type ListStyle

type ListStyle struct {
	Version  int64     `json:"version,omitempty"`
	Name     string    `json:"name,omitempty"`
	Created  time.Time `json:"created,omitempty"`
	ID       string    `json:"id,omitempty"`
	Modified time.Time `json:"modified,omitempty"`
	Owner    string    `json:"owner,omitempty"`
}

ListStyle is a stripped down metadata version of Style returned when listing styles. https://docs.mapbox.com/api/maps/#list-styles

type ListTilesetsParams

type ListTilesetsParams struct {
	Type       *TilesetType
	Visibility *TilesetVisibility
	SortBy     *SortBy
	Limit      *int
}

ListTilesetsParams defines optional parameters for the ListTilesets request.

type SortBy

type SortBy string
const (
	SortByCreated  SortBy = "created"
	SortByModified SortBy = "modified"
)

type Style

type Style struct {
	// Style specification version number. Must be 8.
	Version int `json:"version,omitempty"`
	// A human-readable name for the style.
	Name string `json:"name,omitempty"`
	// Arbitrary properties useful to track with the stylesheet, but do not influence rendering.
	// Properties should be prefixed to avoid collisions, like 'mapbox:'.
	Metadata *json.RawMessage `json:"metadata,omitempty"`
	// Default map center in longitude and latitude.
	// The style center will be used only if the map has not been positioned by other means
	// (e.g. map options or user interaction).
	Center *[2]float64 `json:"center,omitempty"`
	// Default zoom level.
	// The style zoom will be used only if the map has not been positioned by other means
	// (e.g. map options or user interaction).
	Zoom *float64 `json:"zoom,omitempty"`
	// Default bearing, in degrees.
	// The bearing is the compass direction that is "up";
	// for example, a bearing of 90° orients the map so that east is up.
	// This value will be used only if the map has not been positioned by other means
	// (e.g. map options or user interaction).
	Bearing *float64 `json:"bearing,omitempty"`
	// Default pitch, in degrees.
	// Zero is perpendicular to the surface, for a look straight down at the map,
	// while a greater value like 60 looks ahead towards the horizon.
	// The style pitch will be used only if the map has not been positioned by other means
	// (e.g. map options or user interaction).
	Pitch *float64 `json:"pitch,omitempty"`
	// The global light source.
	Light *Light `json:"light,omitempty"`
	// Data source specifications.
	Sources map[string]json.RawMessage `json:"sources,omitempty"`
	// A base URL for retrieving the sprite image and metadata.
	// The extensions .png, .json and scale factor @2x.png will be automatically appended.
	// This property is required if any layer uses the
	// background-pattern, fill-pattern, line-pattern, fill-extrusion-pattern, or icon-image properties.
	// The URL must be absolute, containing the scheme, authority and path components.
	Sprite *string `json:"sprite,omitempty"`
	// A URL template for loading signed-distance-field glyph sets in PBF format.
	// The URL must include {fontstack} and {range} tokens.
	// This property is required if any layer uses the text-field layout property.
	// The URL must be absolute, containing the scheme, authority and path components.
	// For example "mapbox://fonts/mapbox/{fontstack}/{range}.pbf"
	Glyphs *string `json:"glyphs,omitempty"`
	// Layers will be drawn in the order of this array.
	Layers []*Layer `json:"layers,omitempty"`
	// A global transition definition to use as a default across properties,
	// to be used for timing transitions between one value and the next when no property-specific transition is set.
	// Collision-based symbol fading is controlled independently of the style's transition property.
	Transition *Transition `json:"transition,omitempty"`
	// The date and time the style was created.
	Created time.Time `json:"created,omitempty"`
	// The ID of the style.
	Id string `json:"id,omitempty"`
	// The date and time the style was last modified.
	Modified time.Time `json:"modified,omitempty"`
	// The username of the style owner.
	Owner string `json:"owner,omitempty"`
	// Access control for the style, either public or private.
	// Private styles require an access token belonging to the owner.
	// Public styles may be requested with an access token belonging to any user.
	Visibility string `json:"visibility,omitempty"`
	// Indicates whether the style is a draft (true) or whether it has been published (false)
	Draft bool `json:"draft"`
}

https://docs.mapbox.com/mapbox-gl-js/style-spec/root/ https://docs.mapbox.com/api/maps/#the-style-object

func (*Style) Scan

func (s *Style) Scan(src any) error

Make the Style struct implement the sql.Scanner interface. This method simply decodes a JSON-encoded value into the struct fields.

func (Style) Value

func (s Style) Value() (driver.Value, error)

Make the Style struct implement the driver.Valuer interface. This method simply returns the JSON-encoded representation of the struct.

type TileJSON

type TileJSON struct {
	Bounds       [4]float64    `json:"bounds,omitempty"`
	Center       [3]float64    `json:"center,omitempty"`
	Created      int64         `json:"created,omitempty"`
	Format       string        `json:"format,omitempty"`
	MinZoom      int64         `json:"minzoom,omitempty"`
	MaxZoom      int64         `json:"maxzoom,omitempty"`
	Name         string        `json:"name,omitempty"`
	Scheme       string        `json:"scheme,omitempty"`
	TileJSON     string        `json:"tile_json,omitempty"`
	Tiles        []string      `json:"tiles,omitempty"`
	VectorLayers []VectorLayer `json:"vector_layers,omitempty"`
}

type Tileset

type Tileset struct {
	Type        string     `json:"type,omitempty"`
	Center      [3]float64 `json:"center,omitempty"`
	Created     time.Time  `json:"created,omitempty"`
	Description string     `json:"description,omitempty"`
	Filesize    int64      `json:"filesize,omitempty"`
	ID          string     `json:"id,omitempty"`
	Modified    time.Time  `json:"modified,omitempty"`
	Name        string     `json:"name,omitempty"`
	Visibility  string     `json:"visibility,omitempty"`
	Status      string     `json:"status,omitempty"`
}

type TilesetType

type TilesetType string

TilesetType is the data type of the tileset, either "vector" or "raster".

const (
	VectorTileset TilesetType = "vector"
	RasterTileset TilesetType = "raster"
)

type TilesetVisibility

type TilesetVisibility string

TilesetVisibility is either "public" or "private".

const (
	PublicTileset  TilesetVisibility = "public"
	PrivateTileset TilesetVisibility = "private"
)

type Transition

type Transition struct {
	// Duration is the time allotted for transitions to complete.
	Duration int64
	// Delay is the length of time before a transition begins.
	Delay int64
}

Transition controls timing for the interpolation between a style property's previous value and new value. A style's root transition property provides global transition defaults for that style.

type VectorLayer

type VectorLayer struct {
	Description string            `json:"description,omitempty"`
	Fields      map[string]string `json:"fields,omitempty"`
	ID          string            `json:"id,omitempty"`
	MaxZoom     int64             `json:"maxzoom,omitempty"`
	MinZoom     int64             `json:"minzoom,omitempty"`
	Source      string            `json:"source,omitempty"`
	SourceName  string            `json:"source_name,omitempty"`
}

Jump to

Keyboard shortcuts

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