Implementation of the Vector Tile Spec, version 2.1. This package allows you to efficiently build vector tiles including layers and features with geometry and encode them to protobuf.
The following sample shows how to create a simple vector tile with one layer and one point feature:
alias VectorTile.{
Feature,
Layer,
Tile
}
# Create an empty named layer
layer = %Layer{
name: "clusters",
version: 2
}
# Add a feature with attributes
layer = Layer.add_feature(
layer,
Feature.point([128, 128]),
count: 42,
size: "large"
)
# Construct tile
tile = %Tile{
layers: [layer]
}
# Encode to protobuf bytes
Tile.encode(tile)def deps do
[
{:vector_tile, "~> 1.1.0"}
]
end