| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
This package is not in the latest version of its module.
Go to latest Published: Mar 18, 2026 License: MITThe Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Modules with tagged versions give importers more predictable builds.
When a project reaches major version v1 it is considered stable.
Package sm (~ static maps) renders static map images from OSM tiles with markers, paths, and filled areas.
This section is empty.
This section is empty.
CanDisplay checks if pos is generally displayable (i.e. its latitude is in [-85,85])
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(thunderforestApiKey string) map[string]*TileProvider
GetTileProviders returns a map of all available TileProviders
Luminance computes the luminance (~ brightness) of the given color. Range: 0.0 for black to 1.0 for white.
ParseColorString parses hex color strings (i.e. `#RRGGBB`, `RRGGBBAA`, `#RRGGBBAA`), and named colors (e.g. 'black', 'blue', ...)
type Area struct {
MapObject
Positions []s2.LatLng
Color color.Color
Fill color.Color
Weight float64
}
Area represents a area or area on the map
ParseAreaString parses a string and returns an area
Bounds returns the geographical boundary rect (excluding the actual pixel dimensions).
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
ParseCircleString parses a string and returns an array of circles
Bounds returns the geographical boundary rect (excluding the actual pixel dimensions).
type Context struct {
// contains filtered or unexported fields
}
Context holds all information about the map image that is to be rendered
func (m *Context) AddOverlay(overlay *TileProvider)
AddOverlay adds an overlay to the Context
Attribution returns the current attribution string - either the overridden version (using OverrideAttribution) or the one set by the selected TileProvider.
func (m *Context) ClearAreas()
ClearAreas removes all areas from the Context
func (m *Context) ClearCircles()
ClearCircles removes all circles from the Context
func (m *Context) ClearMarkers()
ClearMarkers removes all markers from the Context
func (m *Context) ClearObjects()
ClearObjects removes all objects from the Context
func (m *Context) ClearOverlays()
ClearOverlays removes all overlays from the Context
func (m *Context) ClearPaths()
ClearPaths removes all paths from the Context
OverrideAttribution sets a custom attribution string (or none if empty)
If the attribution string contains newline characters ("\n") it will printed across multiple lines. 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!
Render actually renders the map image including all map objects (markers, paths, areas)
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 (m *Context) RenderWithTransformer() (image.Image, *Transformer, error)
RenderWithTransformer 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.
A Transformer is returned to support image registration with other data.
SetBackground sets the background color (used as a fallback for areas without map tiles)
SetBoundingBox sets the bounding box
SetMaxZoom sets the upper zoom level limit when using dynamic zoom
SetOnline enables/disables online TileFetcher will only fetch tiles from cache if online = false
func (m *Context) SetTileProvider(t *TileProvider)
SetTileProvider sets the TileProvider to be used
SetUserAgent sets the HTTP user agent string used when downloading map tiles
func (m *Context) Transformer() (*Transformer, error)
Transformer returns an initialized Transformer instance.
type ImageMarker struct {
MapObject
Position s2.LatLng
Img image.Image
OffsetX float64
OffsetY float64
}
ImageMarker represents an image marker on the map
NewImageMarker creates a new ImageMarker
func ParseImageMarkerString(s string) ([]*ImageMarker, error)
ParseImageMarkerString parses a string and returns an array of image markers
func (m *ImageMarker) Bounds() s2.Rect
Bounds returns single point rect containing the marker's geographical position.
func (m *ImageMarker) Draw(gc *gg.Context, trans *Transformer)
Draw draws the object in the given graphical context.
func (m *ImageMarker) ExtraMarginPixels() (float64, float64, float64, float64)
ExtraMarginPixels return the marker's left, top, right, bottom pixel extent.
func (m *ImageMarker) SetImage(img image.Image)
SetImage sets the marker's image
func (m *ImageMarker) SetOffsetX(offset float64)
SetOffsetX sets the marker's x offset
func (m *ImageMarker) SetOffsetY(offset float64)
SetOffsetY sets the marker's y offset
type MapObject interface {
// Bounds returns the geographical boundary rect (excluding the actual pixel dimensions).
Bounds() s2.Rect
// ExtraMarginPixels returns the left, top, right, bottom pixel margin of the object.
ExtraMarginPixels() (float64, float64, float64, float64)
// Draw draws the object in the given graphical context.
Draw(dc *gg.Context, trans *Transformer)
}
MapObject is the interface for all objects on the map
type Marker struct {
MapObject
Position s2.LatLng
Color color.Color
Size float64
Label string
LabelColor color.Color
LabelXOffset float64
LabelYOffset float64
}
Marker represents a marker on the map
ParseMarkerString parses a string and returns an array of markers
Bounds returns single point rect containing the marker's geographical position.
func (m *Marker) Draw(gc *gg.Context, trans *Transformer)
Draw draws the object in the given graphical context.
ExtraMarginPixels return the marker's left, top, right, bottom pixel extent.
SetLabelColor sets the color of the marker's text label
Path represents a path or area on the map
ParsePathString parses a string and returns a path
Bounds returns the geographical boundary rect (excluding the actual pixel dimensions).
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 struct {
// contains filtered or unexported fields
}
TileCacheStaticPath provides a static path to the tile fetcher.
func NewTileCache(rootPath string, perm os.FileMode) *TileCacheStaticPath
NewTileCache stores cache files in a static path.
func NewTileCacheFromUserCache(perm os.FileMode) *TileCacheStaticPath
NewTileCacheFromUserCache stores cache files in a user-specific cache directory.
func (c *TileCacheStaticPath) Perm() os.FileMode
Perm instructs the permission to set when creating missing cache directories.
type TileFetcher struct {
// contains filtered or unexported fields
}
TileFetcher downloads map tile images from a TileProvider
func NewTileFetcher(tileProvider *TileProvider, cache TileCache, online bool) *TileFetcher
NewTileFetcher creates a new Tilefetcher struct
func (t *TileFetcher) Fetch(tile *Tile) error
Fetch download (or retrieves from the cache) a tile image for the specified zoom level and tile coordinates
func (t *TileFetcher) SetUserAgent(a string)
SetUserAgent sets the HTTP user agent string used when downloading map tiles
type TileProvider struct {
Name string
Attribution string
IgnoreNotFound bool
TileSize int
URLPattern string // "%[1]s" => shard, "%[2]d" => zoom, "%[3]d" => x, "%[4]d" => y, "%[5]s" => API key
Shards []string
APIKey string
}
TileProvider encapsulates all infos about a map tile provider service (name, url scheme, attribution, etc.)
func NewTileProviderArcgisWorldImagery() *TileProvider
NewTileProviderArcgisWorldImagery creates a TileProvider struct for Arcgis' WorldImagery tiles
func NewTileProviderCarto(name string) *TileProvider
NewTileProviderCarto creates a TileProvider struct for Carto's tile service See https://github.com/CartoDB/basemap-styles?tab=readme-ov-file#1-web-raster-basemaps for available names
func NewTileProviderCartoDark() *TileProvider
NewTileProviderCartoDark creates a TileProvider struct for Carto's tile service (dark variant)
func NewTileProviderCartoLight() *TileProvider
NewTileProviderCartoLight creates a TileProvider struct for Carto's tile service (light variant)
func NewTileProviderNone() *TileProvider
NewTileProviderNone creates a TileProvider struct that does not provide any tiles
func NewTileProviderOpenCycleMap() *TileProvider
NewTileProviderOpenCycleMap creates a TileProvider struct for OpenCycleMap's tile service
func NewTileProviderOpenSeaMap() *TileProvider
NewTileProviderOpenSeaMap creates a TileProvider struct for OpenSeaMap's tile service
func NewTileProviderOpenStreetMaps() *TileProvider
NewTileProviderOpenStreetMaps creates a TileProvider struct for OSM's tile service
func NewTileProviderOpenTopoMap() *TileProvider
NewTileProviderOpenTopoMap creates a TileProvider struct for opentopomap's tile service
func NewTileProviderStamenTerrain() *TileProvider
NewTileProviderStamenTerrain creates a TileProvider struct for stamens' 'terrain' tile service
func NewTileProviderStamenToner() *TileProvider
NewTileProviderStamenToner creates a TileProvider struct for stamens' 'toner' tile service
func NewTileProviderThunderforestLandscape(thunderforestApiKey string) *TileProvider
NewTileProviderThunderforestLandscape creates a TileProvider struct for thundeforests's 'landscape' tile service
func NewTileProviderThunderforestOutdoors(thunderforestApiKey string) *TileProvider
NewTileProviderThunderforestOutdoors creates a TileProvider struct for thundeforests's 'outdoors' tile service
func NewTileProviderThunderforestTransport(thunderforestApiKey string) *TileProvider
NewTileProviderThunderforestTransport creates a TileProvider struct for thundeforests's 'transport' tile service
func NewTileProviderWikimedia() *TileProvider
NewTileProviderWikimedia creates a TileProvider struct for Wikimedia's tile service
func (t TileProvider) IsNone() bool
IsNone returns true if t is an empyt TileProvider (e.g. no configured Url)
type Transformer struct {
// contains filtered or unexported fields
}
Transformer implements coordinate transformation from latitude longitude to image pixel coordinates.
func (t *Transformer) LatLngToXY(ll s2.LatLng) (float64, float64)
LatLngToXY transforms a latitude longitude pair into image x, y coordinates.
func (t *Transformer) Rect() (bbox s2.Rect)
Rect returns an s2.Rect bounding box around the set of tiles described by Transformer.
func (t *Transformer) XYToLatLng(x float64, y float64) s2.LatLng
XYToLatLng transforms image x, y coordinates to a latitude longitude pair.
| Path | Synopsis |
|---|---|
|
examples
|
|
|
idl
command
|
|
|
multiline-attribution
command
|
|
|
overlay
command
|
|
|
stars
command
|
|
|
text-marker
command
|
| Back | FazBrowse Home | New Git URL |