/eschaton

the original gangsta of google maps on rails

Primary LanguageRubyMIT LicenseMIT

eschaton => google maps on rails for bipeds(and also ungulates)

Helps with writing google map mashups in Rails bringing together the Bodacity(measure of bodaciousness) of Google Maps and Rails. If you have an issue please feed-it-back on Github issues

Enough talk, lets code!

#-----------------------------------------------------------------#

map = Google::Map.new(:center => {:latitude => -33.947, :longitude => 18.462},
                      :controls => [:large_map_3D, :map_type])

# A simple map click
map.click do |script, location|
  marker = map.add_marker :location => location
  marker.open_info_window :text => 'Awesome, you added a marker!'
end

#-----------------------------------------------------------------#

# Create a satellite map, zoomed at 16.
map = Google::Map.new(:controls => [:small_map, :map_type],
                      :type => :satellite, :zoom => 16)

# Collect some markers
markers = [[-34.2023, 18.3794], [-34.2029, 18.3797], [-34.2022, 18.3811], 
           [-34.2016, 18.3829], [-34.2006, 18.3849]].collect do |location|
             map.add_marker :location => location
          end

# ... and draw a line in between them
map.add_line :between_markers => markers, :tooltip => {:text => "Short Hike I do everyday with my dog"}

#-----------------------------------------------------------------#

# Draw a polygon, yellow with a green border ..
map.add_polygon :vertices => [[-34.2023, 18.3794], [-34.2029, 18.3797], [-34.2022, 18.3811]], 
                :fill_colour => 'yellow', :border_colour => 'green'  

#-----------------------------------------------------------------#

# A draggable marker that talks when its being dragged and dropped
marker = map.add_marker :location => {:latitude => -33.947, :longitude => 18.462},
                        :tooltip => {:text => "Drag me", :show => :always},
                        :draggable => true

marker.when_being_dragged do
  marker.update_tooltip :text => "Dragging..."
end

marker.when_dropped do |script, drop_location|
  marker.update_tooltip :text => "Dropped..."
  marker.open_info_window :text => "Yes, I was getting tired of flying..."
end

and always remember…

{:latitude => -33.947, :longitude => 18.462} == [-33.947, 18.462]

Checkout the online docs for more general samples.

Get it…

$ script/plugin install git://github.com/yawningman/eschaton.git

Get going…

Generate a map, look at the files the generator created and play a bit.

$ script/generate map

Visit the map at localhost:3000/map or wherever your server runs.

Generate and review the docs, put some test code in the app/helpers/map_helper.rb and play!

$ cd vendor/plugins/eschaton/
$ rake rdoc
$ rake open_doc