Proximity detection and the Voronoi geom
A Voronoi geom chops a geographic shape into discrete regions around points, such that no section overlaps and the entirety of the area is covered. Anything within a particular point's section is closer to that point than to any other point. We're going to use this to figure out what the closest major airport is to your current location, which we'll supply via the HTML5 Geolocation API.
Replace your call to app.get
in chapter6.js
with the following:
app.get('/', (req, res) => { res.send(`<!doctype html> <html> <head> <title>Find your nearest airport!</title> </head> <body> <form method="POST" action="/"> <h1>Enter your latitude and longitude, or allow your browser to check.</h1> <input type="text" name="location" ...
Get D3.js: Cutting-edge Data Visualization now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.