Leaflet.VectorGrid

repository·master·Indexed 20 days ago

https://github.com/leaflet/leaflet.vectorgrid

A plugin for Leaflet 1.0+ used to display gridded vector data, including sliced GeoJSON, TopoJSON, and protobuf vector tiles. It provides the L.VectorGrid.Slicer class for GeoJSON and TopoJSON data, and the L.VectorGrid.Protobuf class for protobuf vector tiles from servers such as OpenMapTiles, MapBox, MapZen, or ESRI.

Tokens
387
Snippets
1
Records
3
Agent score
22%

What's inside leaflet.vectorgrid

  1. Install Leaflet.VectorGrid

    master

    You can install Leaflet.VectorGrid via npm or include it directly in your HTML using unpkg.com.

    Using npm

    Install the package using:

    npm install leaflet.vectorgrid

    This provides two files in the dist/ directory:

    • Leaflet.VectorGrid.js: Use this if you are managing dependencies (like geojson-vt, pbf, topojson, and vector-tile) manually.
    • Leaflet.VectorGrid.bundled.js: Use this if you want a single file that includes all dependencies.

    Using unpkg.com

    For quick integration without npm, add a script tag to your HTML:

    With bundled dependencies:

    <script src="https://unpkg.com/leaflet.vectorgrid@latest/dist/Leaflet.VectorGrid.bundled.js"></script>

    Without bundled dependencies:

    <script src="https://unpkg.com/leaflet.vectorgrid@latest/dist/Leaflet.VectorGrid.js"></script>
  2. Use L.VectorGrid.Slicer for GeoJSON or TopoJSON

    master

    The L.VectorGrid.Slicer class is used to display sliced GeoJSON or TopoJSON data.

    Dependency Requirements:

    • If using GeoJSON: The global variable geojsonvt must be available.
    • If using TopoJSON: The global variable topojson must also be available.

    If you are not using the bundled.js version, you must ensure these dependencies are loaded in your environment.

  3. Use L.VectorGrid.Protobuf for vector tiles

    master

    The L.VectorGrid.Protobuf class is used to display protobuf vector tiles from an online tile server (such as OpenMapTiles, MapBox, MapZen, or ESRI vector tiles).

    Dependency Requirements:

    • The global variables VectorTile and Pbf must be available in the environment.