Using nodejs event streams and leafletjs to display geotagged tweets on a world map

I thought it would be cool to see tweets come in live using the Twitter Streaming API querying with location.  When there is a location bounding box, all tweets that come in have geocoordinates (though a small fraction are null).

Initially I wanted to focus in on a city- Leaflet maps look incredible when you zoom into a city- but the Twitter Streaming API was taking too long to fetch tweets while testing.  I set the bounding box to the world.  You can change the twitter fetch bounding box, as well as the initial mapping bounding box.

This is my first time using them, but from what I understand nodejs event streams allow you to send chunks of data to the browser from the server, as they come in.  This is pretty cool for real time applications.  I wanted to focus this application on immediate tweets, and right now there is no database.  Whenever you run it, you get whatever is coming in the twitter pipeline.

Take a look at the project here.

UPDATE: Note that you need to edit the config.js file with a twitter name and password because querying the streaming API with location is otherwise forbidden.  If you are using an account that already has many apps that query the API constantly (tweet harvesting for example), then you may experience a lag in rate of fetching.  This should not be an issue for most people and can be easily remedied by creating another twitter account to query the API with.

Embed This

4 Responses to “Using nodejs event streams and leafletjs to display geotagged tweets on a world map”

  1. [...] How can you display tweets on an OSM map? You can find an interesting solution here. [...]

  2. [...] can see here I used the same tokens for a previous app, so thats why you see the title has to do with tweet maps.  After the user clicks ‘Authorize [...]

  3. [...] ¿Como puedes mostrar tweets en un mapa OSM? Puedes encontrar una solución interesante aquí. [...]

  4. [...] How can you display tweets on an OSM map? You can find an interesting solution here. [...]

Leave a Reply