Preparing Our Environment for the Earthquake Visualizer
Learn to extract datasets by creating an application that shows earthquakes on a given map.
We'll cover the following...
We’ll build a web application that uses RxJS to show us where earthquakes are happening in real-time, using the concepts that we covered in the previous chapter.
We’ll start by building a functional yet naive reactive implementation, and we’ll improve it as we go.
The final result will look like this:
Environment preparation
We’ll use the
const Rx =require('rx');
var quakes = Rx.Observable.create(function(observer)
{
window.eqfeed_callback = function(response)
{
var quakes = response.features; quakes.forEach(function(quake)
{
observer.onNext(quake);
});
};
loadJSONP(QUAKE_URL);
});
quakes.subscribe(function(quake)
{
var coords = quake.geometry.coordinates;
var size = quake.properties.mag * 10000;
L.circle([coords[1], coords[0]], size).addTo(map);
});Real-time earthquake environment
We’ll also use Leaflet (referred to as L in the code), a JavaScript library, to render interactive maps. In the code shown above, we can see how our ...
Ask