npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

maptalks.formats

v0.3.0

Published

A geospatial format parser for Maptalks

Downloads

102

Readme

CircleCI NPM Version

maptalks.formats

This is a work inspired by leaflet-omnivore.

A maptalks.js's plugin for geographic data format supports, convert various data formats to GeoJSON.

It currently supports:

Installation

download maptalks.formats.min.js from this repository.

or

npm install maptalks.formats --save

example

maptalks.Formats.geojson('a.geojson', function (err, geojson) { });
maptalks.Formats.csv('a.csv', function (err, geojson) { });
maptalks.Formats.gpx('a.gpx', function (err, geojson) { });
maptalks.Formats.kml('a.kml', function (err, geojson) { });
maptalks.Formats.wkt('a.wkt', function (err, geojson) { });
maptalks.Formats.osm('osm.osm', function (err, geojson) { });
maptalks.Formats.topojson('a.topojson', function (err, geojson) { });
maptalks.Formats.polyline('a.txt', function (err, geojson) { });

API

Arguments with ? are optional. parser_options consists of options sent to the parser library:

  • .csv(url, parser_options?, callback): Load & parse CSV. Options are the same as csv2geojson: latfield, lonfield, delimiter
  • .csv.parse(csvString, parser_options?, callback): Parse CSV, and return layer.
  • .kml(url, callback): Load & parse KML.
  • .kml.parse(kmlString | gpxDom): Parse KML from a string of XML or XML DOM.
  • .gpx(url, callback): Load & parse GPX.
  • .gpx.parse(gpxString | gpxDom): Parse GPX from a string of XML or XML DOM.
  • .geojson(url, callback): Load GeoJSON file at URL, parse GeoJSON.
  • .wkt(url, callback): Load & parse WKT.
  • .wkt.parse(wktString): Parse WKT.
  • .topojson(url, callback): Load & parse TopoJSON.
  • .topojson.parse(topojson): Parse TopoJSON (given as a string or object).
  • .osm(url, callback): Parse OSM & Converts OSM XML to GeoJSON.
  • .polyline(url, parser_options?, callback): Load & parse polyline.
  • .polyline.parse(txt, options): Parse polyline (given as a string or object).

Valid options:

polyline

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

Async & Events

Each function returns an maptalks.Formats instance. Functions that load from URLs are asynchronous, so they will not be immediately loaded.

var map = new maptalks.Map('map', options);

maptalks.Formats.gpx('a.gpx', function (err, geojson) {
    // callback when loaded
    new maptalks.VectorLayer('gpx', geojson).addTo(map);
});

Development

git clone [email protected]:maptalks/maptalks.formats.git

cd maptalks.formats

# to run tests
npm install

# to build maptalks.formats.js
npm run build

maptalks.formats.js and maptalks.formats.min.js are built files generated from index.js by rollup. If you find an issue, it either needs to be fixed in index.js, or in one of the libraries maptalks.formats uses to parse formats.

FAQ

  • What if I just want one format? Lucky for you, each format is specified in a different module, so you can just use TopoJSON, csv2geojson, wellknown, or toGeoJSON individually.
  • My AJAX request is failing for a cross-domain request. Read up on the Same Origin Restriction. By default, we use corslite, so cross-domain requests will try to use CORS if your server and browser supports it, but if one of them doesn't, there's no way on the internet to support your request.
  • Why isn't JSONP supported? Here's why.