Documentation ¶
Overview ¶
Package sm (~ static maps) renders static map images from OSM tiles with markers, paths, and filled areas.
Index ¶
- func CreateBBox(nwlat float64, nwlng float64, selat float64, selng float64) (*s2.Rect, error)
- func GetTileProviders() map[string]*TileProvider
- func Luminance(col color.Color) float64
- func ParseColorString(s string) (color.Color, error)
- type Area
- type Context
- func (m *Context) AddArea(area *Area)
- func (m *Context) AddMarker(marker *Marker)
- func (m *Context) AddPath(path *Path)
- func (m *Context) ClearAreas()
- func (m *Context) ClearMarkers()
- func (m *Context) ClearPaths()
- func (m *Context) Render() (image.Image, error)
- func (m *Context) SetBoundingBox(bbox s2.Rect)
- func (m *Context) SetCenter(center s2.LatLng)
- func (m *Context) SetSize(width, height int)
- func (m *Context) SetTileProvider(t *TileProvider)
- func (m *Context) SetZoom(zoom int)
- type MapObject
- type Marker
- type Path
- type TileFetcher
- type TileProvider
- func NewTileProviderCartoDark() *TileProvider
- func NewTileProviderCartoLight() *TileProvider
- func NewTileProviderOpenCycleMap() *TileProvider
- func NewTileProviderOpenStreetMaps() *TileProvider
- func NewTileProviderOpenTopoMap() *TileProvider
- func NewTileProviderStamenTerrain() *TileProvider
- func NewTileProviderStamenToner() *TileProvider
- func NewTileProviderThunderforestLandscape() *TileProvider
- func NewTileProviderThunderforestOutdoors() *TileProvider
- func NewTileProviderThunderforestTransport() *TileProvider
- func NewTileProviderWikimedia() *TileProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateBBox ¶
CreateBBox creates a bounding box from a north-western point (lat/lng in degrees) and a south-eastern point (lat/lng in degrees). Note that you can create a bounding box wrapping over the antimeridian at lng=+-/180° by nwlng > selng.
func GetTileProviders ¶
func GetTileProviders() map[string]*TileProvider
GetTileProviders returns a map of all available TileProviders
Types ¶
type Area ¶
type Area struct { MapObject Positions []s2.LatLng Color color.Color Fill color.Color Weight float64 }
Area represents a area or area on the map
func ParseAreaString ¶
ParseAreaString parses a string and returns an area
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context holds all information about the map image that is to be rendered
func (*Context) ClearAreas ¶
func (m *Context) ClearAreas()
ClearAreas removes all areas from the Context
func (*Context) ClearMarkers ¶
func (m *Context) ClearMarkers()
ClearMarkers removes all markers from the Context
func (*Context) ClearPaths ¶
func (m *Context) ClearPaths()
ClearPaths removes all paths from the Context
func (*Context) Render ¶
Render actually renders the map image including all map objects (markers, paths, areas)
func (*Context) SetBoundingBox ¶
SetBoundingBox sets the bounding box
func (*Context) SetTileProvider ¶
func (m *Context) SetTileProvider(t *TileProvider)
SetTileProvider sets the TileProvider to be used
type MapObject ¶
type MapObject interface {
// contains filtered or unexported methods
}
MapObject is the interface for all objects on the map
type Marker ¶
type Marker struct { MapObject Position s2.LatLng Color color.Color Size float64 Label string LabelColor color.Color }
Marker represents a marker on the map
func ParseMarkerString ¶
ParseMarkerString parses a string and returns an array of markers
func (*Marker) SetLabelColor ¶
SetLabelColor sets the color of the marker's text label
type Path ¶
Path represents a path or area on the map
func ParsePathString ¶
ParsePathString parses a string and returns a path
type TileFetcher ¶
type TileFetcher struct {
// contains filtered or unexported fields
}
TileFetcher downloads map tile images from a TileProvider
func NewTileFetcher ¶
func NewTileFetcher(tileProvider *TileProvider) *TileFetcher
NewTileFetcher creates a new Tilefetcher struct
func (*TileFetcher) Fetch ¶
func (t *TileFetcher) Fetch(zoom, x, y int) (image.Image, error)
Fetch download (or retrieves from the cache) a tile image for the specified zoom level and tile coordinates
func (*TileFetcher) ToggleCaching ¶
func (t *TileFetcher) ToggleCaching(enabled bool)
ToggleCaching enables/disables caching
type TileProvider ¶
type TileProvider struct { Name string Attribution string TileSize int URLPattern string // "%[1]s" => shard, "%[2]d" => zoom, "%[3]d" => x, "%[4]d" => y Shards []string }
TileProvider encapsulates all infos about a map tile provider service (name, url scheme, attribution, etc.)
func NewTileProviderCartoDark ¶
func NewTileProviderCartoDark() *TileProvider
NewTileProviderCartoDark creates a TileProvider struct for Carto's tile service (dark variant)
func NewTileProviderCartoLight ¶
func NewTileProviderCartoLight() *TileProvider
NewTileProviderCartoLight creates a TileProvider struct for Carto's tile service (light variant)
func NewTileProviderOpenCycleMap ¶
func NewTileProviderOpenCycleMap() *TileProvider
NewTileProviderOpenCycleMap creates a TileProvider struct for OpenCycleMap's tile service
func NewTileProviderOpenStreetMaps ¶
func NewTileProviderOpenStreetMaps() *TileProvider
NewTileProviderOpenStreetMaps creates a TileProvider struct for OSM's tile service
func NewTileProviderOpenTopoMap ¶
func NewTileProviderOpenTopoMap() *TileProvider
NewTileProviderOpenTopoMap creates a TileProvider struct for opentopomap's tile service
func NewTileProviderStamenTerrain ¶
func NewTileProviderStamenTerrain() *TileProvider
NewTileProviderStamenTerrain creates a TileProvider struct for stamens' 'terrain' tile service
func NewTileProviderStamenToner ¶
func NewTileProviderStamenToner() *TileProvider
NewTileProviderStamenToner creates a TileProvider struct for stamens' 'toner' tile service
func NewTileProviderThunderforestLandscape ¶
func NewTileProviderThunderforestLandscape() *TileProvider
NewTileProviderThunderforestLandscape creates a TileProvider struct for thundeforests's 'landscape' tile service
func NewTileProviderThunderforestOutdoors ¶
func NewTileProviderThunderforestOutdoors() *TileProvider
NewTileProviderThunderforestOutdoors creates a TileProvider struct for thundeforests's 'outdoors' tile service
func NewTileProviderThunderforestTransport ¶
func NewTileProviderThunderforestTransport() *TileProvider
NewTileProviderThunderforestTransport creates a TileProvider struct for thundeforests's 'transport' tile service
func NewTileProviderWikimedia ¶
func NewTileProviderWikimedia() *TileProvider
NewTileProviderWikimedia creates a TileProvider struct for Wikimedia's tile service