Cartographer plugin

Plugin details

Ruby on Rails :: Google Maps plugin

Websitehttp://cartographer.rubyforge.org/ Repositorysvn://rubyforge.org//var/svn/cartographer/trunk Author Courtenay Gasking Tags Maps LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install svn://rubyforge.org//var/svn/cartographer/trunk

First you need to sign up for an API key

Then, put your API key into the vendor/plugins/cartographer/lib/keys.rb file.

Open up your layout template (if you're using one) and insert this code into the HEAD section:

< head>
  <%= gmaps_header %>
  ...
< /head>



Now, in your controller* define your map and set up some markers.

def map
  @map = Cartographer::Map.new( :name => 'mymap', :width => 300, :center => [-110,33], :debug => true)
  @map.markers << Cartographer::Marker.new( :position => [-110,33], :info_window => 'Clicky clicky!!', :map => @map )
end



* Realistically this can also be in your view, but it's a bit naughty of you to consider bending MVC!

Finally, render the map in your view.

<%= @map.to_html >



If you view the source to this page, you'll see what the above lines of code look like in the rendered code (below this point). You can remove the :debug => true if you don't want commenting (it will compress the code a little, too)

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: hardway, 7 months ago