Skip to content

Instantly share code, notes, and snippets.

@matiaskorhonen
Created July 8, 2019 07:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matiaskorhonen/cc9b62490202eb4818b2997074f42a0f to your computer and use it in GitHub Desktop.
Save matiaskorhonen/cc9b62490202eb4818b2997074f42a0f to your computer and use it in GitHub Desktop.
Build a map of all the Euruko cities
#!/usr/bin/env ruby
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "addressable"
gem "nokogiri"
gem "pry"
end
CITIES = [
{ year: 2005, city: "Berlin, Germany", coordinates: [13.388889, 52.516667] },
{ year: 2006, city: "Munich, Germany", coordinates: [11.566667, 48.133333] },
{ year: 2007, city: "Vienna, Austria", coordinates: [16.366667, 48.2] },
{ year: 2008, city: "Prague, Czech Republic", coordinates: [14.416667, 50.083333] },
{ year: 2009, city: "Barcelona, Spain", coordinates: [2.183333, 41.383333] },
{ year: 2010, city: "Krakow, Poland", coordinates: [19.937222, 50.061389] },
{ year: 2011, city: "Berlin, Germany", coordinates: [13.388889, 52.516667] },
{ year: 2012, city: "Amsterdam, Netherlands", coordinates: [4.9, 52.366667] },
{ year: 2013, city: "Athens, Greece", coordinates: [23.727806, 37.983972] },
# { year: 2014, city: "Kyiv, Ukraine", coordinates: [30.523333, 50.45] },
{ year: 2015, city: "Salzburg, Austria", coordinates: [13.033333, 47.8] },
{ year: 2016, city: "Sofia, Bulgaria", coordinates: [23.33, 42.7] },
{ year: 2017, city: "Budapest, Hungary", coordinates: [19.051389, 47.4925] },
{ year: 2018, city: "Vienna, Austria", coordinates: [16.366667, 48.2] },
{ year: 2019, city: "Rotterdam, Netherlands", coordinates: [4.5, 51.916667] },
{ year: 2020, city: "Helsinki, Finland", coordinates: [24.9375, 60.170833] }
]
access_token = "pk.SOMETHING" # TODO: replace this
map_template = Addressable::Template.new("https://api.mapbox.com/styles/v1/mapbox/outdoors-v11/static/{overlay}/8.2118,56.1545,3.0,0,0/1280x720@2x?access_token={access_token}")
overlays = CITIES.map do |city|
"pin-l+E65947(#{city[:coordinates].join(",")})"
end
puts map_template.expand(
access_token: access_token,
overlay: overlays.join(",")
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment