GithubHelp home page GithubHelp logo

bkane11 / geojson-vt Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mapbox/geojson-vt

0.0 2.0 0.0 946 KB

Slice GeoJSON into vector tiles on the fly in the browser

License: ISC License

JavaScript 97.78% HTML 2.22%

geojson-vt's Introduction

geojson-vt โ€” GeoJSON Vector Tiles

A highly efficient JavaScript library for slicing GeoJSON data into vector tiles on the fly, primarily designed to enable rendering and interacting with large geospatial datasets on the browser side (without a server).

Created to power GeoJSON in Mapbox GL JS, but can be useful in other visualization platforms like Leaflet and d3. It can also be easily used on the server as well.

Resulting tiles conform to the JSON equivalent of the vector tile specification. To make data rendering and interaction fast, the tiles are simplified, retaining the minimum level of detail appropriate for each zoom level (simplifying shapes, filtering out tiny polygons and polylines).

Demo

Here's geojson-vt action in Mapbox GL JS, dynamically loading a 100Mb US zip codes GeoJSON with 5.4 million points:

There's a convenient debug page to test out geojson-vt on different data. Make sure you have the dev version built; open debug/index.html in your browser, and drag any GeoJSON on the page, watching the console.

Usage

// build an initial index of tiles
var tileIndex = geojsonvt(geoJSON);

// request a particular tile
var features = tileIndex.getTile(z, x, y).features;

Options

You can fine-tune the results with an options object, although the defaults are sensible and work well for most use cases.

var tileIndes = 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
});

Browser builds

npm install
npm run build-dev # development build, used by the debug page
npm run build-min # minified production build

Changelog

2.0.0 (Mar 20, 2015)
  • Breaking: maxZoom renamed to indexMaxZoom, maxPoints to indexMaxPoints, baseZoom to maxZoom.
  • Improved performance of both indexing and on-demand tile requests.
  • Improved memory footprint.
  • Better indexing defaults.
  • Fixed a bug where unnecessary memory was retained in some cases.
1.1.0 (Mar 2, 2015)
  • Add buffer and extent options.
1.0.0 (Dec 8, 2014)
  • Initial release.

geojson-vt's People

Contributors

fitnr avatar incanus avatar mourner 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.