Realtime London Underground Position

page created at 2017-04-21 by Daniel Leite

raw_data <- getURL("http://traintimes.org.uk/map/tube/data/london.json")

data <- fromJSON(raw_data, flatten = TRUE)
trains <- data$trains
trains["lat"] <- sapply(data$trains$point, function(x) x[1])
trains["long"] <- sapply(data$trains$point, function(x) x[2])

subicon <- makeIcon("http://cdn2.iconfinder.com/data/icons/circle-icons-1/64/train-32.png", 32, 32)
trains %>% 
  leaflet() %>%
  addTiles() %>%
  addMarkers(popup = trains$title, icon = subicon)
## Assuming 'long' and 'lat' are longitude and latitude, respectively
Leaflet | © OpenStreetMap contributors, CC-BY-SA