Skip to content

inaturalist/elasticmaps

Repository files navigation

Elasticmaps

Build Status Coverage Status

A Node.js map tile server based on node-mapnik and elasticsearch

Installation

npm install elasticmaps --save

Usage

// This is the most basic example. It assumes elasticsearch
// is running on http://localhost:9200, and that there is an index
// named elasticmaps_development which has documents with minimally
// an integer `id` and geo_point `location` field

const Elasticmaps = require( "elasticmaps" );
const port = Number( process.env.PORT || 4000 );

const app = Elasticmaps.server( );
// create the tile route
app.get( "/:style/:zoom/:x/:y.:format([a-z\.]+)", Elasticmaps.route );

app.listen( port, ( ) => {
  console.log( "Listening on " + port );
} );

// In this example a custom config object is supplied
// when creating the server. Functions can be provided
// to create custom queries and styles based on the request

const Elasticmaps = require( "elasticmaps" );
const port = Number( process.env.PORT || 4000 );

const config =  {
  environment: "production",
  debug: true,
  tileSize: 256,
  elasticsearch: {
    host: "http://localhost:9200",
    searchIndex: "points_index",
    geoPointField: "location"
  },
  prepareQuery: req => {
    req.elastic_query = ...;
  },
  prepareStyle: req => {
    req.style = ...;
  }
};

const server = Elasticmaps.server( config );
server.listen( port, ( ) => {
  console.log( "Listening on " + port );
} );

About

Map tileserver based on node-mapnik and elasticsearch

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published