November 2017
Beginner to intermediate
298 pages
6h 47m
English
Before we draw the airports, we manipulate the airport locations data. We create an array holding one GeoJSON point geometry object per airport:
var airportLocation = [];airports.forEach(function(el) { var obj = {}; obj.type = 'Feature'; obj.id = el.iata; obj.geometry = { type: 'Point', coordinates: [+el.long, +el.lat] }; obj.properties = {}; airportLocation.push(obj);});airportMap = d3.map(airportLocation, function(d) { return d.id; });
Then we fill the global airportMap variable with a map we produce with d3.map(). d3.map() is a utility function that takes an array of objects to produce key-value pairs we can access with its own map.get() method. We won't use the map immediately but will get to it in a moment. ...
Read now
Unlock full access