box-o-sand/map-mash/app/controllers/maps_controller.rb
Dan Buch d834b81003 Add 'map-mash/' from commit '7f16409d1257e7471fef35c18bcdf32856b908e3'
git-subtree-dir: map-mash
git-subtree-mainline: eacc351b17
git-subtree-split: 7f16409d12
2013-01-09 23:59:47 -05:00

29 lines
622 B
Ruby

class MapsController < ApplicationController
def index
@maps = Map.all
respond_to do |format|
format.html
format.xml { render :xml => @maps }
end
end
def show
@map = Map.find(params[:id])
respond_to do |format|
format.png do
GoogleMapLocationFetcher.new.fetch([@map.name]) do |loc,image|
dest = Rails.root.join("public/maps/#{@map.id}.png")
FileUtils.mkdir_p(File.dirname(dest))
File.open(dest, 'w') do |f|
f.write(image)
end
send_file(dest, :type => 'image/png')
end
end
end
end
end