A Node.js map tile server based on node-mapnik and elasticsearch
npm install elasticmaps --save
// 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 );
} );