Google Script, Twitter API & Google Maps

Image taken from page 12 of ‘Guide to Cambridge: the town, university and colleges … To which are added, notes upon the villages within ten miles, a map, etc’ flickr photo by The British Library shared with no copyright restriction (Flickr Commons)

This is more playing with Martin‘s TAGs in Google Script and then moving it into Google Maps for visuals . . . the TAGS related functions will only work in that context but the purse Google stuff should work in any spreadsheet.

Get Twitter Location by Account

This function will get the user’s location as defined by their profile. So =getLoc(“twoodwar”) would return Richmond VA.

function getLoc(input){
  var theTweet = TAGS.get('users/show',{id: input});
  var theLoc = theTweet.location;
  return theLoc;  

This function will get the lat/long via Google Script. So =getLl(“Richmond, VA”) would return 37.5407246, -77.4360481. Keep in mind if it’s trying to get the lat/lng for someone who put “the Interwebz” as their location like OnlineCrsLady then your lat/lng may not work out that well.

function getLl(input) {
  var geo = input;
  var response = Maps.newGeocoder().geocode(geo);
  response = response.results[0];
  return +', '+response.geometry.location.lng;

So that’ll let us take a chunk of TAGs data.1 and do something like this with Google Maps.

I’m not going to break this chunk down quite yet. I did it at very odd hours and it works but it’s not very clean and I know there are ways to do it better.There is no shame in my game but there is some bashfulness.
Pretend I’m an internet version of Bambi’s Thumper. Ordinarily that’d be a terrible image to put in someone’s head but given our current scenario it seems almost refreshing.

See the Pen Google Sheets to Google Maps by Tom (@twwoodward) on CodePen.

1 Martin Hawksey forever.