Gathering detailed insights and metrics for @mapbox/leaflet-omnivore
Gathering detailed insights and metrics for @mapbox/leaflet-omnivore
Gathering detailed insights and metrics for @mapbox/leaflet-omnivore
Gathering detailed insights and metrics for @mapbox/leaflet-omnivore
universal format parser for Leaflet & Mapbox.js
npm install @mapbox/leaflet-omnivore
Typescript
Module System
Node Version
NPM Version
61.2
Supply Chain
90.9
Quality
77.7
Maintenance
25
Vulnerability
90
License
JavaScript (92.64%)
HTML (7.36%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
NOASSERTION License
664 Stars
103 Commits
127 Forks
146 Watchers
4 Branches
627 Contributors
Updated on Jul 10, 2025
Latest Version
0.3.4
Package Id
@mapbox/leaflet-omnivore@0.3.4
Size
30.89 kB
NPM Version
4.0.2
Node Version
4.6.2
Published on
Dec 02, 2016
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Leaflet supports the GeoJSON format by default. What if you have something else? That's where omnivore comes in.
It currently supports:
Omnivore also includes an AJAX library, corslite, so you can specify what you want to add to the map with just a URL.
use it easily with the Mapbox Plugins CDN:
1<script src='//api.tiles.mapbox.com/mapbox.js/plugins/leaflet-omnivore/v0.3.1/leaflet-omnivore.min.js'></script>
Or download leaflet-omnivore.min.js
from this repository.
Live examples:
1var map = L.mapbox.map('map', 'mapbox.streets') 2 .setView([38, -102.0], 5); 3 4omnivore.csv('a.csv').addTo(map); 5omnivore.gpx('a.gpx').addTo(map); 6omnivore.kml('a.kml').addTo(map); 7omnivore.wkt('a.wkt').addTo(map); 8omnivore.topojson('a.topojson').addTo(map); 9omnivore.geojson('a.geojson').addTo(map); 10omnivore.polyline('a.txt').addTo(map);
Arguments with ?
are optional. parser_options consists of options
sent to the parser library, not to the layer: if you want to provide options
to the layer, see the example in the Custom Layers section.
By default, the library will construct a L.geoJson()
layer internally and
call .addData(geojson)
on it in order to load it full of GeoJSON. If you want
to use a different kind of layer, like a L.mapbox.featureLayer()
, you can,
by passing it as customLayer
, as long as it supports events and addData()
.
You can also use this API to pass custom options to a L.geoJson()
instance.:
.csv(url, parser_options?, customLayer?)
: Load & parse CSV, and return layer. Options are the same as csv2geojson: latfield, lonfield, delimiter
.csv.parse(csvString, parser_options?)
: Parse CSV, and return layer..kml(url)
: Load & parse KML, and return layer..kml.parse(kmlString | gpxDom)
: Parse KML from a string of XML or XML DOM, and return layer..gpx(url, parser_options?, customLayer?)
: Load & parse GPX, and return layer..gpx.parse(gpxString | gpxDom)
: Parse GPX from a string of XML or XML DOM, and return layer..geojson(url, parser_options?, customLayer?)
: Load GeoJSON file at URL, parse GeoJSON, and return layer..wkt(url, parser_options?, customLayer?)
: Load & parse WKT, and return layer..wkt.parse(wktString)
: Parse WKT, and return layer..topojson(url, parser_options?, customLayer?)
: Load & parse TopoJSON, and return layer..topojson.parse(topojson)
: Parse TopoJSON (given as a string or object), and return layer..polyline(url, parser_options?, customLayer?)
: Load & parse polyline, and return layer..polyline.parse(txt, options, layer)
: Parse polyline (given as a string or object), and return layer.Valid options:
precision
will change how the polyline is interpreted. By default, the value
is 5. This is the factor in the algorithm,
by default 1e5, which is adjustable.Passing custom options:
1var customLayer = L.geoJson(null, { 2 filter: function() { 3 // my custom filter function 4 return true; 5 } 6}); 7 8var myLayer = omnivore.csv('foo', null, customLayer);
Adding custom styles to a GeoJSON layer:
1var customLayer = L.geoJson(null, {
2 // http://leafletjs.com/reference.html#geojson-style
3 style: function(feature) {
4 return { color: '#f00' };
5 }
6});
7// this can be any kind of omnivore layer
8var runLayer = omnivore.kml('line.kml', null, customLayer)
Using a L.mapbox.featureLayer
:
1var layer = omnivore.gpx('a.gpx', null, L.mapbox.featureLayer());
Each function returns an L.geoJson
object. Functions that load from URLs
are asynchronous, so they will not immediately expose accurate .setGeoJSON()
functions.
For this reason, we fire events:
ready
: fired when all data is loaded into the layererror
: fired if data can't be loaded or parsed1var layer = omnivore.gpx('a.gpx') 2 .on('ready', function() { 3 // when this is fired, the layer 4 // is done being initialized 5 }) 6 .on('error', function() { 7 // fired if the layer can't be loaded over AJAX 8 // or can't be parsed 9 }) 10 .addTo(map);
ready
does not fire if you don't use an asynchronous form of the function
like .topojson.parse()
: because you don't need an event. Just run your code
after the call.
This is a browserify project:
1git clone git@github.com:mapbox/leaflet-omnivore.git 2 3cd leaflet-omnivore 4 5# to run tests 6npm install 7 8# to build leaflet-omnivore.js 9npm run build
leaflet-omnivore.js
and leaflet-omnivore.min.js
are built files generated
from index.js
by browserify
. If you find an issue, it either needs to be
fixed in index.js
, or in one of the libraries leaflet-omnivore uses
to parse formats.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
security policy file detected
Details
Reason
license file detected
Details
Reason
branch protection is not maximal on development and all release branches
Details
Reason
Found 6/25 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More