Skip to content

BONUS Part 6. Add Tweet Locations

Rachel edited this page Mar 31, 2017 · 7 revisions

pubnubscreeniemaps

Want to add maps to your dashboard that show which areas of the world are the most positive/negative/neutral?

Just run the pubnubStreamLocation.py script or the pubnubStreamLocation.js script instead!

But first you have to get a Google API key and install the geolocation module based on Google Maps.

Get a Google API Key

From the geolocation python page:

  1. Visit the APIs console at https://code.google.com/apis/console and log in with your Google account
  2. Click the Services link from the left-hand menu and activate the Geocoding API service
  3. Your API key should now be available from the API Access page in the Simple API Access section

Copy-paste this key into line 8.

Install the Geocode Module

Python

Install the geolocation module:

pip install geolocation-python

Node

Install the geolocation module:

npm install @google/maps

Note: If you receive a permissions error, add "sudo" to the front of the command

For Node, edit the IBM Watson Block

To get location data from Twitter and then stream it based on the associated tweet's score, I just added 2 lines to the IBM Watson block inside of my PubNub app. You can copy that block code here. Be sure to put your IBM API key on line 13!

Don't Forget

Add your PubNub subscribe and publish keys to this script too!

The Map tiles should automatically pop up inside of your Initial State bucket.

<< Part 5: Your Personal Dashboard - BONUS - Part 7: The Unlimited Stream >>

Clone this wiki locally