myTravelMap

John Walker
3 Mar 2016

alt text

My Travel Map - a shiny application

I've had the chance to live in and travel to some different places so for the course project decided to make a map displaying the locations and providing some selection. A vanity project to be sure.

To start I created a list of places identifying the type of location and the year I was there. Location types are

  • Home: moved the family and our things
  • Project: worked on a project for a month of more (didn't move)
  • Meeting: business trip
  • Travel: personal travel

Data Preparation

First built a list of locations as a .csv file using Excel. The columns are town, location type and year:

              town LocType Year
1 Evanston, IL, US    Home 1974

The 'geocode function from the ggmaps library finds the latitude and longitude based on the town and country code:

geoCodes <- geocode(myLocs$town)
myLocs$Lat <- geoCodes$lat ; myLocs$Long <- geoCodes$lon
str(myLocs)
'data.frame':   3 obs. of  5 variables:
 $ town   : chr  "Evanston, IL, US" "Istanbul, TR" "Rome, IT"
 $ LocType: Factor w/ 3 levels "Home","Meeting",..: 1 3 2
 $ Year   : num  1974 2007 1987
 $ Lat    : num  42 41 41.9
 $ Long   : num  -87.7 29 12.5

UI Controls and the Map display

The list of locations is saved as an RDS file in the shiny application directory to be read by the server code at startup.

The user interface provides selection for each of the location types, the range of years to include and a selection of color palettes for the map points by location type.

The map is plotted using the plotGoogleMaps function and is set to resize based on the points to be included. Here's a static image of the app:

alt text

Links and Acknowledgements

The shiny travel map app is here

The Github for the app code and data is here

I'd like to thank PereG on Stackoverflow for a helpful example of mapping points

and RamnanthV the creator of shiny and slidify for the iframe example.

The plotGoogleMaps function stores html output so the iframe allows the html to be displayed in a shiny app.