Giter VIP home page Giter VIP logo

nodetiles-core's Introduction

Nodetiles-Core

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 CartCSS 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 slipply-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

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

nodetiles-core's People

Contributors

bensheldon avatar eddietejeda avatar mr0grog avatar yuletide avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.