
Security News
AI Slop Is Polluting Bug Bounty Platforms with Fake Vulnerability Reports
AI-generated slop reports are making bug bounty triage harder, wasting maintainer time, and straining trust in vulnerability disclosure programs.
leaflet.vectorgrid
Advanced tools
Display gridded vector data (sliced GeoJSON or protobuf vector tiles) in Leaflet 1.0.0
Because neither Leaflet.MapboxVectorTile nor Hoverboard will work on Leaflet 1.
With sliced GeoJSON: http://ivansanchez.github.io/Leaflet.VectorGrid/dist/demo/demo-geojson.html
With sliced TopoJSON: http://ivansanchez.github.io/Leaflet.VectorGrid/dist/demo/demo-topojson.html (sorry for the antimeridian mess, topojson-to-geojson seems to not handle it properly)
With protobuf VectorTile
s: http://ivansanchez.github.io/Leaflet.VectorGrid/dist/demo/demo-vectortiles.html
Install through npm
with npm install leaflet.vectorgrid
.
This will make available some browser-ready files, which include the bundled dependencies:
This plugin exposes two new classes:
L.VectorGrid.Slicer
Slices some GeoJSON data into tiles, via geojson-vt
.
Instantiate through the factory method:
var layer = L.vectorGrid.slicer(geojson, options);
Any options to geojson-vt
can be passed in options
.
Styling-wise, this will create an internal vector tile layer named sliced
. This can be overridden with the vectorTileLayerName
option.
The slicer also accepts TopoJSON transparently:
var layer = L.vectorGrid.slicer(topojson, options);
The TopoJSON format implicitly groups features into "objects". These will be transformed into vector tile layer names when styling (the vectorTileLayerName
option is ignored when using TopoJSON).
L.VectorGrid.Protobuf
Reads vector tiles in Protobuf (.pbf
) format from the network.
Instantiate through the factory method:
var layer = L.vectorGrid.protobuf(url, options);
url
is a URL template for .pbf
vector tiles, e.g.:
var url = 'https://{s}.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/{z}/{x}/{y}.vector.pbf';
var layer = L.vectorGrid.protobuf(url, options);
Vector tiles have a concept of "layer" different from the Leaflet concept of "layer".
In Leaflet, a "layer" is something that can be atomically added or removed from the map. In vector tiles, a "layer" is a named set of features (points, lines or polygons) which share a common theme.
A vector tile layer¹ can have several layers². In the mapbox-streets-v6
vector tiles layer¹ above, there are named layers² like admin
, water
or roads
.
Styling is done via per-layer² sets of L.Path
options in the vectorTileLayerStyles
layer¹ option:
var vectorTileOptions = {
vectorTileLayerStyles: {
water: {
weight: 0,
fillColor: '#9bc2c4',
fillOpacity: 1,
fill: true
},
admin: function(properties, zoom) {
var level = properties.admin_level;
var weight = 1;
if (level == 2) {weight = 4;}
return {
weight: weight,
color: '#cf52d3',
dashArray: '2, 6',
fillOpacity: 0
}
},
road: []
}
};
var pbfLayer = L.vectorGrid.protobuf(url, vectorTileOptions).addTo(map);
A layer² style can be either:
L.Path
optionsL.Path
optionsL.Path
optionsL.Path
optionsLayers² with no style specified will use the default L.Path
options.
<canvas>
Leaflet.VectorGrid is able to render vector tiles with both SVG and <canvas>
, in the same way that vanilla Leaflet can use SVG and <canvas>
to draw lines and polygons.
To switch between the two, use the rendererFactory
option for any L.VectorGrid
layer, e.g.:
var sliced = L.vectorGrid.slicer(geojson, {
rendererFactory: L.svg.tile,
attribution: 'Something',
vectorTileLayerStyles: { ... }
});
var pbf = L.vectorGrid.protobuf(url, {
rendererFactory: L.canvas.tile,
attribution: 'Something',
vectorTileLayerStyles: { ... }
});
Internally, Leaflet.VectorGrid uses two classes named L.SVG.Tile
and L.Canvas.Tile
, with factory methods L.svg.tile
and L.canvas.tile
- a L.VectorGrid
needs to be passed one of those factory methods.
L.VectorGrid.Slicer
requires geojson-vt
: the global variable geojsonvt
must exist. If topojson data is used, then the topojson
global variable must also exist.
L.VectorGrid.Protobuf
requires vector-tile
and pbf
: the global variables VectorTile
and Pbf
must exist.
Run npm install
, then run the aux/browserify-dependencies.sh
script. The dependencies do not provide browser-ready packages, see for example mapbox/geojson-vt#52.
<g>
roups in SVG
** Offscreen <canvas>
es in Canvas"THE BEER-WARE LICENSE": ivan@sanchezortega.es wrote this file. As long as you retain this notice you can do whatever you want with this stuff. If we meet some day, and you think this stuff is worth it, you can buy me a beer in return.
FAQs
Display gridded vector data (sliced GeoJSON or protobuf vector tiles) in Leaflet 1.0
The npm package leaflet.vectorgrid receives a total of 6,940 weekly downloads. As such, leaflet.vectorgrid popularity was classified as popular.
We found that leaflet.vectorgrid demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
AI-generated slop reports are making bug bounty triage harder, wasting maintainer time, and straining trust in vulnerability disclosure programs.
Research
Security News
The Socket Research team investigates a malicious Python package disguised as a Discord error logger that executes remote commands and exfiltrates data via a covert C2 channel.
Research
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.