GithubHelp home page GithubHelp logo

isabella232 / nodetiles-init Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nodetiles/nodetiles-init

0.0 0.0 0.0 1.19 MB

An example server showing off how awesome Nodetiles is

Home Page: http://nodetiles.herokuapp.com/

JavaScript 100.00%

nodetiles-init's Introduction

Nodetiles-init

This is an example webserver for use with the nodetiles-core library, a fully-featured map rendering library for Node.js. This code is meant to be a convenient starting place for using Nodetiles to build a slippy-map — including Leaflet, Wax, and default asset/image routes — but is by no means only way to use the nodetiles-core library.

Screenshot of nodetiles-server

Installation

After downloading, be sure to install the dependencies (this may require installing cairo and pixman):

$ npm install

Then start the server:

$ node server.example.js

And visit the webpage: http://localhost:3000

Configuration

This Nodetiles example can be easily configured by modifying the node.server.js file; the map configuration starts around line 30:

// Create the new map
var map = new nodetiles.Map();

// Add a datasource named 'world" from the countries.geojson file
map.addData(new GeoJsonSource({ 
  name: "world",
  path: __dirname + '/map/data/countries.geojson', 
  projection: "EPSG:900913"
}));

// Add a 2nd geojson datasource
map.addData(new GeoJsonSource({ 
  name: "example",
  path: __dirname + '/map/data/example.geojson', 
  projection: "EPSG:4326"
}));

// Link to your Mapnik style sheet
map.addStyle(fs.readFileSync('./map/theme/style.mss','utf8'));

This data is then rendered into map tiles on-the-fly when the web map framework (Wax+Leaflet) make a GET request to the appropriate map tile URL: /:row/:column/:zoom.png.

You can easily add new GeoJSON files… or PostGIS files via the PostGIS data connector:

map.addData(newPostGISSource({
  connectionString: "tcp://postgres@localhost/postgis", // required
  tableName: "ogrgeojson",                              // required
  geomField: "wkb_geometry",                            // required
  fields: "map_park_n, ogc_fid",                        // optional, speeds things up
  name: "sf_parks",                                     // optional, uses table name otherwise
  projection: 900913,                                   // optional, defaults to 4326
});

Data

example data Natural Earth projected to 900913 with zipit

nodetiles-init's People

Contributors

bensheldon avatar yuletide avatar mr0grog 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.