2012-03-07 14:32:33 +00:00
|
|
|
class MapsController < ApplicationController
|
|
|
|
def index
|
|
|
|
@maps = Map.all
|
|
|
|
|
|
|
|
respond_to do |format|
|
2012-03-08 04:43:32 +00:00
|
|
|
format.html
|
|
|
|
format.xml { render :xml => @maps }
|
2012-03-07 14:32:33 +00:00
|
|
|
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
|
2012-03-08 01:02:03 +00:00
|
|
|
send_file(dest, :type => 'image/png')
|
2012-03-07 14:32:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|