Socket
Socket
Sign inDemoInstall

nodetiles-core

Package Overview
Dependencies
27
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    nodetiles-core

Joyful map rendering with Node.js.


Version published
Weekly downloads
2
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Nodetiles-Core

Build Status Dependency Status Coverage Status Code Climate NPM version

Nodetiles-core is a javascript library for rendering map tiles suitable for slippy-maps and static images. Features include:

  • Flexible Data-connectors: We offer GeoJson and Shapefile connectors out-of-the-box, but it's easy to build your own.
  • Map Projections: Transform data between more 3,900+ EPSG projections using Proj4.js
  • CartoCSS Support: We support many (if not most) stylesheet features of CartoCSS making it trivial to import your map styles from tools like Tilemill
  • Slippy-map URL helpers: Easily serve map tiles, UTFGrids, and Tile.json. Check out nodetiles-init for a simple scaffold.
  • Static maps: If slippy-maps aren't your style, generate static images of any dimension; checkout nodetiles-example-static for examples.
  • Joyfully simple, pluggable, flexible, powerful: We built Nodetiles to be easily understandable, extensible and a joy to use. It's built with Javascript and tries to provide a solid foundation of tools that are still easy to understand, extend or replace depending on your needs. File an issue if Nodetiles can't do what you need.

Screenshot

Nodetiles Screenshot

Example

/* Set up the libraries */
var nodetiles = require('nodetiles-core'),
    GeoJsonSource = nodetiles.datasources.GeoJson,
    Projector = nodetiles.projector,
    fs = require('fs'); // we'll output to a file

/* Create your map context */
var map = new nodetiles.Map({
    projection: "EPSG:4326" // set the projection of the map
});

/* Add some data */
map.addData(new GeoJsonSource({
  name: "world",
  path: __dirname + '/countries.geojson',
  projection: "EPSG:900913"
}));

/* Link your Carto stylesheet */
map.addStyle(fs.readFileSync('./style.mss','utf8'));

/* Render out the map to a file */
map.render({
  // Make sure your bounds are in the same projection as the map
  bounds: {minX: -180, minY: -90, maxX: 180, maxY: 90},
  width: 800,   // number of pixels to output
  height: 400,
  callback: function(err, canvas) {
    var file = fs.createWriteStream(__dirname + '/map.png'),
        stream = canvas.createPNGStream();

    stream.on('data', function(chunk){
      file.write(chunk);
    });

    stream.on('end', function(){
      console.log('Saved map.png!');
    });
  }
});


Thanks

Big THANKS to Tom Carden whose original gist inspired this project. He also has other very useful projects.

Projections

Supported projections

Copyright (c) 2012-2015 Code for America. See LICENSE for details.

FAQs

Last updated on 26 Apr 2015

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc