Rails Google Maps Plugin
I still remember the awe that struck me when I first saw for the first time Google Maps in action. I was able zoom in and out, and even circumnavigate the globe by just clicking and moving the cursor around. Google Maps really demonstrated what a web 2.0 mashup could be like. Housing Maps is mashup between Google Maps and Craigslist apartment/housing ads. If you want show all the locations of Wi-Fi hot spots in your Rails app like Hotspotr, then you need to take a look at Yellow Maps 4 Ruby on Rails Plugin for Google Maps.
Before you get started you will need to sign up for a Google Maps API access. Once you have your Maps API key install the Rails plugin by executing the ‘script/plugin install <URL>’ command from your application directory where URL is replaced with the following.
<%= GMap.header %>
In the controller you instantiate a GMap object with a id name. You will also need to supply the center of the map with the longitude and latitude and the zoom factor. If you want a little map balloon to appear you will need to create a marker. Your map can have any number of markers, each position separately with a title and info window when clicked. Here is the code used to construct a map, which can be placed in your controller.
@map = GMap.new("map_div_id") @map.control_init(:large_map => true, :map_type => true) @map.center_zoom_init([75.5,-42.56], 4) marker = GMarker.new([75.6, -42.467], :title => "Where Am I?", :info_window => "Hello, Greenland") @map.overlay_init(marker)
<%= @map.to_html %> <%= @map.div(:width => 600, :height => 400) %>