Skip to content

do-me/Leaflet.MapboxVectorTile

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

195 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Leaflet.MapboxVectorTile

Fork from https://github.com/SpatialServer/Leaflet.MapboxVectorTile.

Why fork a 10-year old project for an outdated Leaflet release (0.77)? Read the answer here: SpatialServer#89

This fork just adds support for custom drawing functions for more complex geometric shapes like hearts, stars or custom polygons. You can also color specific parts of the shapes based on properties.

Only dist/Leaflet.MapboxVectorTile.js and the examples are modified.

Options

For static icons use e.g.

  • style.draw = drawStar;

For dynamic ones where you need to add feature properties like a score, use this function

  • style.draw = function(ctx, x, y, size) {drawCircleWithGreyOutlineAndDotColor(ctx, x, y, size, feature.properties.score); };

Example

You can use tippecanoe for converting geojson to mbtiles and mbtileserver to serve as pbf.

  1. Install go, then
go install github.com/consbio/mbtileserver@latest
export PATH=$PATH:$(go env GOPATH)/bin
  1. Install tippecanoe from https://github.com/felt/tippecanoe

  2. Create test point geojson with geo.rocks/coordinates2, download geojson (or use the one in this repo)

  3. Convert geojson to mbtiles in tilesets folder: tippecanoe -o tilesets/coordinates.mbtiles coordinates.geojson -z24 --drop-rate=1 --force

  4. Run mbtiles go server with mbtileserver coordinates.mbtiles -p 8000

  5. Run a simple webserver for the static files in this repo, like npx serve

  6. Modify the functions and observe the changes.

Examples:

image

image

image

About

A Leaflet Plugin that renders Mapbox Vector Tiles on HTML5 Canvas. Legacy software for Leaflet <1 & vector tiles.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 98.7%
  • Other 1.3%