geojson-vt

WebJar for geojson-vt

License

License

ISC
Categories

Categories

Geo Business Logic Libraries Geospatial JSON Data
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

geojson-vt
Last Version

Last Version

3.2.1
Release Date

Release Date

Type

Type

jar
Description

Description

geojson-vt
WebJar for geojson-vt
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/mapbox/geojson-vt

Download geojson-vt

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/geojson-vt/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>geojson-vt</artifactId>
    <version>3.2.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/geojson-vt/
implementation 'org.webjars.npm:geojson-vt:3.2.1'
// https://jarcasting.com/artifacts/org.webjars.npm/geojson-vt/
implementation ("org.webjars.npm:geojson-vt:3.2.1")
'org.webjars.npm:geojson-vt:jar:3.2.1'
<dependency org="org.webjars.npm" name="geojson-vt" rev="3.2.1">
  <artifact name="geojson-vt" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='geojson-vt', version='3.2.1')
)
libraryDependencies += "org.webjars.npm" % "geojson-vt" % "3.2.1"
[org.webjars.npm/geojson-vt "3.2.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

geojson-vt — GeoJSON Vector Tiles

Build Status

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, OpenLayers and d3, as well as Node.js server applications.

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).

Read more on how the library works on the Mapbox blog.

There's a C++11 port: geojson-vt-cpp

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. Just 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;

// show an array of tile coordinates created so far
console.log(tileIndex.tileCoords); // [{z: 0, x: 0, y: 0}, ...]

Options

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

var tileIndex = geojsonvt(data, {
	maxZoom: 14,  // max zoom to preserve detail on; can't be higher than 24
	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)
	lineMetrics: false, // whether to enable line metrics tracking for LineString/MultiLineString features
	promoteId: null,    // name of a feature property to promote to feature.id. Cannot be used with `generateId`
	generateId: false,  // whether to generate feature ids. Cannot be used with `promoteId`
	indexMaxZoom: 5,       // max zoom in the initial tile index
	indexMaxPoints: 100000 // max number of points per tile in the index
});

By default, tiles at zoom levels above indexMaxZoom are generated on the fly, but you can pre-generate all possible tiles for data by setting indexMaxZoom and maxZoom to the same value, setting indexMaxPoints to 0, and then accessing the resulting tile coordinates from the tileCoords property of tileIndex.

The promoteId and generateId options ignore existing id values on the feature objects.

GeoJSON-VT only operates on zoom levels up to 24.

Install

Install using NPM (npm install geojson-vt) or Yarn (yarn add geojson-vt), then:

// import as a ES module
import geojsonvt from 'geojson-vt';

// or require in Node / Browserify
const geojsonvt = require('geojson-vt');

Or use a browser build directly:

<script src="https://unpkg.com/[email protected]/geojson-vt.js"></script>
org.webjars.npm

Mapbox

Mapbox is the location data platform for mobile and web applications. We're changing the way people move around cities and explore our world.

Versions

Version
3.2.1
3.2.0
3.0.0
2.4.0
2.1.8
2.1.0