Draw Mapbox Vector Tiles (MVT) in Go
Draw Mapbox Vector Tiles with ease.
go get -u github.com/tidwall/mvt
var tile mvt.Tile
l := tile.AddLayer("triforce")
f := l.AddFeature(mvt.Polygon)
f.MoveTo(128, 96)
f.LineTo(148, 128)
f.LineTo(108, 128)
f.LineTo(128, 96)
f.ClosePath()
f.MoveTo(148, 128)
f.LineTo(168, 160)
f.LineTo(128, 160)
f.LineTo(148, 128)
f.ClosePath()
f.MoveTo(108, 128)
f.LineTo(128, 160)
f.LineTo(88, 160)
f.LineTo(108, 128)
f.ClosePath()
data := tile.Render()
// Data now contains a valid mapbox vector tile protobuf
// for sending over the internets and styling to your
// heart's content.
mvt.LatLonXY
: Converts a lat/lon to the pixel offset for a specific tile.mvt.TileBounds
: Returns the lat/lon boundary for a tile.Josh Baker @tidwall
mvt source code is available under the MIT License.