Documentation ¶
Overview ¶
Package sm (~ static maps) renders static map images from OSM tiles with markers, paths, and filled areas.
Index ¶
- func CanDisplay(pos s2.LatLng) bool
- 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 Circle
- type Context
- func (m *Context) AddArea(area *Area)
- func (m *Context) AddCircle(circle *Circle)
- func (m *Context) AddMarker(marker *Marker)
- func (m *Context) AddOverlay(overlay *TileProvider)
- func (m *Context) AddPath(path *Path)
- func (m *Context) ClearAreas()
- func (m *Context) ClearCircles()
- func (m *Context) ClearMarkers()
- func (m *Context) ClearOverlays()
- func (m *Context) ClearPaths()
- func (m *Context) OverrideAttribution(attribution string)
- func (m *Context) Render() (image.Image, error)
- func (m *Context) RenderWithBounds() (image.Image, s2.Rect, error)
- func (m *Context) SetBackground(col color.Color)
- func (m *Context) SetBoundingBox(bbox s2.Rect)
- func (m *Context) SetCache(cache TileCache)
- func (m *Context) SetCenter(center s2.LatLng)
- func (m *Context) SetSize(width, height int)
- func (m *Context) SetTileFetcher(tf TileFetcher)
- func (m *Context) SetTileProvider(t *TileProvider)
- func (m *Context) SetUserAgent(a string)
- func (m *Context) SetZoom(zoom int)
- type FileTileFetcher
- type MapObject
- type Marker
- type MemTileFetcher
- type NewTileFetcherFunc
- type Path
- type TileCache
- type TileCacheStaticPath
- 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 CanDisplay ¶
CanDisplay checks if pos is generally displayable (i.e. its latitude is in [-85,85])
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 Circle ¶
type Circle struct { MapObject Position s2.LatLng Color color.Color Fill color.Color Weight float64 Radius float64 // in m. }
Circle represents a circle on the map
func ParseCircleString ¶
ParseCircleString parses a string and returns an array of circles
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) AddOverlay ¶
func (m *Context) AddOverlay(overlay *TileProvider)
AddOverlay adds an overlay to the Context
func (*Context) ClearAreas ¶
func (m *Context) ClearAreas()
ClearAreas removes all areas from the Context
func (*Context) ClearCircles ¶
func (m *Context) ClearCircles()
ClearCircles removes all circles from the Context
func (*Context) ClearMarkers ¶
func (m *Context) ClearMarkers()
ClearMarkers removes all markers from the Context
func (*Context) ClearOverlays ¶
func (m *Context) ClearOverlays()
ClearOverlays removes all overlays from the Context
func (*Context) ClearPaths ¶
func (m *Context) ClearPaths()
ClearPaths removes all paths from the Context
func (*Context) OverrideAttribution ¶
OverrideAttribution sets a custom attribution string (or none if empty)
Pay attention you might be violating the terms of usage for the selected map provider - only use the function if you are aware of this!
func (*Context) Render ¶
Render actually renders the map image including all map objects (markers, paths, areas)
func (*Context) RenderWithBounds ¶
RenderWithBounds actually renders the map image including all map objects (markers, paths, areas). The returned image covers requested area as well as any tiles necessary to cover that area, which may be larger than the request.
Specific bounding box of returned image is provided to support image registration with other data
func (*Context) SetBackground ¶
SetBackground sets the background color (used as a fallback for areas without map tiles)
func (*Context) SetBoundingBox ¶
SetBoundingBox sets the bounding box
func (*Context) SetTileFetcher ¶
func (m *Context) SetTileFetcher(tf TileFetcher)
SetTileFetcher sets the Tile ftecher instantior func
func (*Context) SetTileProvider ¶
func (m *Context) SetTileProvider(t *TileProvider)
SetTileProvider sets the TileProvider to be used
func (*Context) SetUserAgent ¶
SetUserAgent sets the HTTP user agent string used when downloading map tiles
type FileTileFetcher ¶
type FileTileFetcher struct {
// contains filtered or unexported fields
}
FileTileFetcher downloads map tile images from a TileProvider
func (*FileTileFetcher) Fetch ¶
func (t *FileTileFetcher) 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 (*FileTileFetcher) SetUserAgent ¶
func (t *FileTileFetcher) SetUserAgent(a string)
SetUserAgent sets the HTTP user agent string used when downloading map tiles
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 MemTileFetcher ¶
type MemTileFetcher struct {
// contains filtered or unexported fields
}
MemTileFetcher downloads map tile images from a TileProvider
func (*MemTileFetcher) Fetch ¶
func (t *MemTileFetcher) 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 (*MemTileFetcher) SetUserAgent ¶
func (t *MemTileFetcher) SetUserAgent(a string)
SetUserAgent sets the HTTP user agent string used when downloading map tiles
type NewTileFetcherFunc ¶
type NewTileFetcherFunc func(*TileProvider, TileCache) TileFetcher
NewTileFetcherFunc signature of the function that instantiates a new tile fetcher
type Path ¶
Path represents a path or area on the map
func ParsePathString ¶
ParsePathString parses a string and returns a path
type TileCache ¶
type TileCache interface { // Root path to store cached tiles in with no trailing slash. Path() string // Permission to set when creating missing cache directories. Perm() os.FileMode }
TileCache provides cache information to the tile fetcher
type TileCacheStaticPath ¶
type TileCacheStaticPath struct {
// contains filtered or unexported fields
}
TileCacheStaticPath provides a static path to the tile fetcher.
func NewTileCache ¶
func NewTileCache(rootPath string, perm os.FileMode) *TileCacheStaticPath
NewTileCache stores cache files in a static path.
func NewTileCacheFromUserCache ¶
func NewTileCacheFromUserCache(name string, perm os.FileMode) *TileCacheStaticPath
NewTileCacheFromUserCache stores cache files in a user-specific cache directory.
func (*TileCacheStaticPath) Perm ¶
func (c *TileCacheStaticPath) Perm() os.FileMode
Perm instructs the permission to set when creating missing cache directories.
type TileFetcher ¶
TileFetcher interface
func NewFileTileFetcher ¶
func NewFileTileFetcher(tileProvider *TileProvider, cache TileCache) TileFetcher
NewFileTileFetcher creates a new Tilefetcher struct
func NewMemTileFetcher ¶
func NewMemTileFetcher(tileProvider *TileProvider, cache TileCache) TileFetcher
NewMemTileFetcher creates a new Tilefetcher struct
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