Git Product home page Git Product logo

eschaton's Introduction

eschaton => google maps on rails for humans

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-back on Github issues

If you find the plugin useful and wish to donate something, please donate the equivalent in money or your time to your local charities, plant a tree that is indigenous to your area or lend your support to people who truly need it.

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

Say you want to show your friends how you would hop across a crater on Mars. We also want to include the google search bar, incase we want to sight see whilst on Mars.

map = Google::Map.new(:controls => [:small_map, :map_type], :type => :mars_elevation,
                      :zoom => 6)

map.enable_google_bar! # For sight seeing

hops = [[-0.252, 14.414], [-0.977, 15.446], [-1.735, 16.094],
        [-2.679, 16.171], [-4.346, 16.600], [-4.598, 17.116],
        [-6.271, 19.379]]

hops.each do |location|                  
  tooltip_text = if location == hops.first
                   'Start here!'
                 elsif location == hops.last
                   'End here!'
                 else
                   'Hop'
                 end

  marker = map.add_marker :location => location, :tooltip => {:text => tooltip_text, :show => :always}
  marker.click do
    marker.open_info_window :text => "Its really hot in this crater!"
  end
end

Both Hashes and Arrays can represent a Location, so use which ever form you prefer.

{: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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.