Skip to content

Instantly share code, notes, and snippets.

@manuelbieh
Created October 20, 2011 10:57
Show Gist options
  • Save manuelbieh/1300892 to your computer and use it in GitHub Desktop.
Save manuelbieh/1300892 to your computer and use it in GitHub Desktop.
node.js Geolib Example
var app = require('express').createServer(),
fs = require('fs'),
geolib = require('./geolib').geolib,
http = require('http');
app.get('/distance/:lat1/:lng1/:lat2/:lng2', function(req, res){
var distance = geolib.getDistance({latitude: req.params.lat1, longitude: req.params.lng1 }, {latitude: req.params.lat2, longitude: req.params.lng2});
res.send('Distance from ' + req.params.lat1 + ',' + req.params.lng1 + ' to ' + req.params.lat2 + ',' + req.params.lng2 + ' is ' + distance + ' km');
});
app.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment