Method: Nyaplot::MapPlot#add_map
- Defined in:
- lib/mapnya/plot.rb
#add_map(name, data = nil) ⇒ Object
Add the map of individual countries instead of world map
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/mapnya/plot.rb', line 34 def add_map(name, data=nil) if data.nil? path = File.("../datasets/countries/data/" + name.downcase + ".geo.json", __FILE__) map_data = JSON.parse(File.read(path)) # pre-processing map_data["features"].push(map_data["features"][0]) if map_data["features"].length == 1 country_data = Countries.df.filter{|row| row[:cca3] == name.upcase}.row(0) center([country_data[:lng], country_data[:lat]]) map_data(map_data) else map_data(data) end end |