Skip to content

Gmaps4rails makes it easy to create Maps with Ruby on Rails 3. It uses Google Maps API V3.

Notifications You must be signed in to change notification settings

michaelkeenan/Google-Maps-for-Rails

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Maps for Rails (gmaps4rails)

Gmaps4rails is developed to simply create a Google Map (Gmaps):

  • directly from your model,

  • from your own json

It’s based on Ruby on Rails 3 Engines and uses Google Maps API V3.

Installation

gem install gmaps4rails

Requirements

  • <%= yield :head %> (in your header)

  • <%= yield :scripts %> (in your footer)

  • config.serve_static_assets = true (in your production.rb), or copy/paste gmaps4rails.css & gmaps4rail.js files in your app.

Basic configuration

In your model, add:

acts_as_gmappable

def gmaps4rails_address self.address #describe how to retrieve the address from your model end

Create a migration and add the following fields to your table (here users):

add_column :users, :latitude, :float #you can change the name, see wiki add_column :users, :longitude, :float #you can change the name, see wiki add_column :users, :gmaps, :boolean #not mandatory, see wiki

How to?

QuickStart!

In your controller:

@json = User.all.to_gmaps4rails

In your view:

<%= gmaps4rails(@json) %>

Done!

Options

  • Markers with Info window, Custom Picture

  • Circles, Polylines, Polygons

  • Geocode directly your address and retrieve coordinates.

  • Wrapper for ‘Direction’, giving instructions to go from point A to point B

  • Auto-adjust the map to your markers

  • Refresh your map on the fly with Javascript (and Ajax)

  • More details in the Wiki

Todo?

Feel free to contact us, you have your say.

MIT license.

Authors: Benjamin Roth, David Ruyer

Contributor: Alex Vorobiev

About

Gmaps4rails makes it easy to create Maps with Ruby on Rails 3. It uses Google Maps API V3.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 66.3%
  • JavaScript 33.7%