func NewTileRenderer(stylesheet string) *TileRenderer { t := new(TileRenderer) var err error if err != nil { log.Fatal(err) } t.m = mapnik.NewMap(256, 256) t.m.Load(stylesheet) t.mp = t.m.Projection() return t }
// Render a simple map of europe to a PNG file func SimpleExample() { m := mapnik.NewMap(1600, 1200) defer m.Free() m.Load("sampledata/stylesheet.xml") fmt.Println(m.SRS()) // Perform a projection that is only neccessary because stylesheet.xml // is using EPSG:3857 rather than WGS84 p := m.Projection() ll := p.Forward(mapnik.Coord{0, 35}) // 0 degrees longitude, 35 degrees north ur := p.Forward(mapnik.Coord{16, 70}) // 16 degrees east, 70 degrees north m.ZoomToMinMax(ll.X, ll.Y, ur.X, ur.Y) blob, err := m.RenderToMemoryPng() if err != nil { fmt.Println(err) return } ioutil.WriteFile("mapnik.png", blob, 0644) }