Skip to content

Instantly share code, notes, and snippets.

@davidpiesse
Last active January 31, 2018 15:55
Show Gist options
  • Save davidpiesse/658f74e41b3317a7c99335743b66e4d0 to your computer and use it in GitHub Desktop.
Save davidpiesse/658f74e41b3317a7c99335743b66e4d0 to your computer and use it in GitHub Desktop.
Earthquake Stream Connection - Pusher

Earthquake.stream

To connect to Earthquake Streams data feed you need to use a pusher library such as https://github.com/pusher/pusher-js

Live Demo Code @ https://codepen.io/mapdev/pen/XaexdY

Required Keys

To connect you need

  • Pusher Key: cb8e92ce5edfd617ee0a
  • Pusher Cluster: mt1
  • Event Name: earthquake
  • Channels [all]

Channels

Currently there is only the one channel all but other will be available soon

There are 6 channels:

  • all
  • minor
  • light
  • strong
  • significant
  • tsunami
  • All data is fired to a earthquake event
  • All earthquake alerts are sent to the all channel
  • Significant earthquakes are sent to the significant channel
  • Earthquakes that may create a tsunami are sent to the tsunami channel
  • The other three channels, minor, light, and strong are based on magnitudes <2.5, <4.5, and >4.5 respectivily

Code

Below is a code snippet to connect in JavaScript

Include this in the <head>

<script src="https://js.pusher.com/4.1/pusher.min.js"></script>

Setup Pusher

var pusher = new Pusher('cb8e92ce5edfd617ee0a', {
  cluster: 'mt1'
});

Connect to a specific channel

var channel = pusher.subscribe('all');

Listen for an earthquake

channel.bind('earthquake', function(data) {
  console.log(data);
});
@wowcut
Copy link

wowcut commented Aug 23, 2017

I can not see any data on the site. I see a never-ending spinner with text 'Awaiting New Earthquake Detection' - it is not clear if this is the intended view for 'no earthquakes right now' or if the site is broken. Also I can not find the issue tracker here on github so I can not report, that is why I am writing here.

@davidpiesse
Copy link
Author

Hi @wowcut - Earthquake Stream has been in hibernation and has only just been restarted. Should be working now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment