Skip to content

brandonxiang/leaflet-geojson-vt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

leaflet-geojson-vt

This is a plugin combining geojson-vt with leafletjs, which is inspired by geojson-vt-leaflet. I am the original author of leaflet-geojson-vt. iamtekson/leaflet-geojson-vt is a fork of this repo. Welcome to use this plugin.

If you use leaflet 0.7, please switch to the leaflet0.7.7.

Usage

var options = {
    maxZoom: 16,
    tolerance: 3,
    debug: 0,
    style: {
        fillColor: '#1EB300',
        color: '#F2FF00',
        weight: 2
    }
};
var canvasLayer = L.gridLayer.geoJson(json, options).addTo(map);

Options are included with geojson-vt options and L.geojson style.

var tileIndex = geojsonvt(data, {
    maxZoom: 14,  // max zoom to preserve detail on
    tolerance: 3, // simplification tolerance (higher means simpler)
    extent: 4096, // tile extent (both width and height)
    buffer: 64,   // tile buffer on each side
    debug: 0      // logging level (0 to disable, 1 or 2)

    indexMaxZoom: 4,        // max zoom in the initial tile index
    indexMaxPoints: 100000, // max number of points per tile in the index
    solidChildren: false    // whether to include solid tile children in the index
});

Development

run npm script with browser-sync

npm run dev

Browser on http://localhost:3000/example

TODO

  • point interactive
  • new branch to compatiable with 1.0.0
  • more geojson style
  • convert to included class of L.TileLayer.Canvas
  • different canvas layers
  • style for polygon and polyline
  • layers change
  • seperate index.js into index.js and app.js
  • draw point on canvas
  • draw marker by image(cancel)

Changelog

changelog

License

brandonxiang@MIT