/cartographer

Google Maps on Rails

Primary LanguageRuby

Cartographer generates painless Google Maps for your Rails application.

In your controller:

def index
  @spots = Spot.find(:all) # Your Geocoded location model
  @map = Cartographer::Gmap.new("spots", :zoom => :bound, :controls => [:small,:scale], :debug => true)
  @spots.each do |spot|
    @map.markers << Cartographer::Gmarker.new(:name => "spot_" + spot.id.to_s, :position => [spot.lat, spot.lng], :info_window => spot.description)
  end
end

In your view

  <%= @map.to_html %>

You will need:

A Google Maps API key (put it in config/cartographer-config.yaml)
Geocoded locations (easily done with Geokit -- http://geokit.rubyforge.org/)

Current Version:

v0.1 08 May 2008
* Original Rubyforge version with some small edits

History:

Original Rails blog announcement is at http://download.rubyonrails.com/2005/8/30/cartographer-effortless-google-maps-in-rails, but the Rubyforge project page is dead.  So I'm bringing it back.