Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Enables easy display of items (taken from a Rails 3 model) with Google Map, OpenLayers, Bing or Mapquest. Geocoding + Directions included. Provides much options: markers customization, infowindows, auto-adjusted zoom, polylines, polygons, circles etc... See wiki for full description and examples.
Ruby CoffeeScript JavaScript

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
app
config
history
lib
public
test/dummy
.DS_Store
.gitignore
LICENSE.txt
README.rdoc
Rakefile
VERSION
gmaps4rails.gemspec

README.rdoc

Google Maps for Rails (gmaps4rails)

Gmaps4rails is developped to simply create a Google Map:

  • directly from your model,

  • from your own json

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

Requirements

  • gem 'gmaps4rails' (in your gemfile, then bundle)

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

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

  • config.serve_static_assets = true (in your production.rb), or copy/paste gmaps4rails.css & gmaps4rails.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

  • Automatic sidebar with list of markers

  • 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 ton contact us, you have your say.

Copyright

MIT license.

Authors: Benjamin Roth, David Ruyer

Contributor: Alex Vorobiev

Something went wrong with that request. Please try again.