https://github.com/vicapow/go-vtile-example
An example go server for serving vector tiles
https://github.com/vicapow/go-vtile-example
Last synced: 4 months ago
JSON representation
An example go server for serving vector tiles
- Host: GitHub
- URL: https://github.com/vicapow/go-vtile-example
- Owner: vicapow
- Created: 2016-07-05T01:34:40.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-07-30T06:20:45.000Z (over 9 years ago)
- Last Synced: 2025-04-03T08:12:57.188Z (9 months ago)
- Language: Go
- Size: 5.67 MB
- Stars: 55
- Watchers: 3
- Forks: 13
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-vector-tiles - go-vtile-example - An example server written in Go (Servers)
README
# An example Go app for dynamically serving MapboxGL vector tiles

## Installation
To install, ensure github.com/golang/protobuf/proto is installed and available on your $GOPATH.
## To run the project
`cd` into the project directory, then run:
go run main.go
## Docker
To install/run in Docker instead of natively:
```
docker build -t go-vtile-example .
docker run -d -p 8080:8080 go-vtile-example
```
## To view the tiles
To view the tiles, you'll need to modify your MapboxGL style to add an additional vector tile layer. Here's an example:
```
var map = new mapboxgl.Map({
container: 'map',
zoom: 12.5,
center: [-122.45, 37.79],
style: {
version: 8,
sources: {},
layers: []
},
hash: false
});
map.on('load', function loaded() {
map.addSource('custom-go-vector-tile-source', {
type: 'vector',
tiles: ['http://localhost:8080/tiles/{z}/{x}/{y}']
});
map.addLayer({
id: 'background',
type: 'background',
paint: {
'background-color': 'white'
}
});
map.addLayer({
"id": "custom-go-vector-tile-layer",
"type": "circle",
"source": "custom-go-vector-tile-source",
"source-layer": "points",
paint: {
'circle-radius': {
stops: [[8, 0.1], [11, 0.5], [15, 3], [20, 20]]
},
'circle-color': '#e74c3c',
'circle-opacity': 1
}
});
});
```
## Data from SFGov.org
https://data.sfgov.org/City-Infrastructure/Street-Tree-Map/337t-q2b4