Documentation ¶
Overview ¶
Package mapnik renders beautiful maps with Mapnik.
Index ¶
- Variables
- func Encode(img image.Image, format string) ([]byte, error)
- func LogSeverity(level LogLevel)
- func RegisterDatasources(path string) error
- func RegisterFonts(path string) error
- type LayerSelector
- type LogLevel
- type Map
- func (m *Map) BackgroundColor() color.NRGBA
- func (m *Map) Free()
- func (m *Map) Load(stylesheet string) error
- func (m *Map) Render(opts RenderOpts) ([]byte, error)
- func (m *Map) RenderImage(opts RenderOpts) (*image.NRGBA, error)
- func (m *Map) RenderToFile(opts RenderOpts, path string) error
- func (m *Map) ResetLayers()
- func (m *Map) ResetMaxExtent()
- func (m *Map) Resize(width, height int)
- func (m *Map) SRS() string
- func (m *Map) ScaleDenominator() float64
- func (m *Map) SelectLayers(selector LayerSelector) bool
- func (m *Map) SetBackgroundColor(c color.NRGBA)
- func (m *Map) SetBufferSize(s int)
- func (m *Map) SetMaxExtent(minx, miny, maxx, maxy float64)
- func (m *Map) SetSRS(srs string)
- func (m *Map) ZoomAll() error
- func (m *Map) ZoomTo(minx, miny, maxx, maxy float64)
- type RenderOpts
- type SelectorFunc
- type Status
Constants ¶
This section is empty.
Variables ¶
var ( None = LogLevel(C.MAPNIK_NONE) Debug = LogLevel(C.MAPNIK_DEBUG) Warn = LogLevel(C.MAPNIK_WARN) Error = LogLevel(C.MAPNIK_ERROR) )
var Version version
Functions ¶
func Encode ¶
Encode image.Image with Mapniks image encoder. This is optimized for *image.NRGBA or *image.RGBA.
func LogSeverity ¶
func LogSeverity(level LogLevel)
LogSeverity sets the global log level for Mapnik. Requires a Mapnik build with logging enabled.
func RegisterDatasources ¶
RegisterDatasources registers all input plugins found in the given path.
func RegisterFonts ¶
RegisterDatasources registers all fonts found in the given path.
Types ¶
type LayerSelector ¶
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map base type
func (*Map) BackgroundColor ¶
func (*Map) Load ¶
Load reads in a Mapnik map XML.
Note: Since Mapnik 3 all layers with status="off" are not loaded and cannot be activated by a custom LayerSelector. As a workaround, all layers with names starting with '__OFF__' are disabled on load and the '__OFF__' prefix is removed from the layer name.
func (*Map) Render ¶
func (m *Map) Render(opts RenderOpts) ([]byte, error)
Render returns the map as an encoded image.
func (*Map) RenderImage ¶
func (m *Map) RenderImage(opts RenderOpts) (*image.NRGBA, error)
RenderImage returns the map as an unencoded image.Image.
func (*Map) RenderToFile ¶
func (m *Map) RenderToFile(opts RenderOpts, path string) error
RenderToFile writes the map as an encoded image to the file system.
func (*Map) ResetLayers ¶
func (m *Map) ResetLayers()
ResetLayer resets all layers to the initial status.
func (*Map) ResetMaxExtent ¶
func (m *Map) ResetMaxExtent()
func (*Map) Resize ¶
Resize changes the map size in pixel. Sizes larger than 16k pixels are ignored by Mapnik. Use NewSized to initialize larger maps.
func (*Map) ScaleDenominator ¶
ScaleDenominator returns the current scale denominator. Call after Resize and ZoomAll/ZoomTo.
func (*Map) SelectLayers ¶
func (m *Map) SelectLayers(selector LayerSelector) bool
SelectLayers enables/disables single layers. LayerSelector or SelectorFunc gets called for each layer. Returns true if at least one layer was included (or set to default).
func (*Map) SetBackgroundColor ¶
func (*Map) SetBufferSize ¶
SetBufferSize sets the pixel buffer at the map image edges where Mapnik should not render any labels.
func (*Map) SetMaxExtent ¶
type RenderOpts ¶
type RenderOpts struct { // Scale renders the map at a fixed scale denominator. Scale float64 // ScaleFactor renders the map with larger fonts sizes, line width, etc. For printing or retina/hq iamges. ScaleFactor float64 // Format for the rendered image ('jpeg80', 'png256', etc. see: https://github.com/mapnik/mapnik/wiki/Image-IO) Format string }
RenderOpts defines rendering options.
type SelectorFunc ¶
func (SelectorFunc) Select ¶
func (f SelectorFunc) Select(layername string) Status