Giter VIP home page Giter VIP logo

go-vtile-example's Introduction

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

go-vtile-example's People

Contributors

vicapow avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.