Plugin details

Mappa is a Rails plug-in map-creation API for creating maps embedded in html web pages. Presently it only supports Google's Gmap2 API.
It was written primarily because of the hacks required to make the Cartographer.rb rails plugin work with the new Gmap2 API.

Following on from a basic implementation I got frustrated with the amount of javascript I was having to embed within my controller code, a necessity because of the dynamic nature of many of the maps (and map creation techniques) I was using. The result was the latest version of mappa which enables you to build your map javascript from external files.

You need a google API key to use this plugin. This may be obtained by visiting http://www.google.com/apis/maps/signup.html. The API used in this example will suffice for testing as long as you are using the following testing url: http://localhost:3000

This plugin is under constant development but is being used without any problems in production in spotcrime.net. Any amendments, suggestions, etc. are welcomed.

Websitehttp://neverintheoffice.net Repository svn://neverintheoffice.net/mappa/trunk/mappa Author Andy Mendelsohn Tags Google, Maps, Geo LicenseUnknown

Documentation

Install the plugin:
ruby script/plugin install  svn://neverintheoffice.net/mappa/trunk/mappa

The following quick example should produce a basic map.

map_controller.rb :

class MapController < ApplicationController

  def index
    
   @page_title = "Create new map"

   @gmap = Mappa::GMap.new()
   # the gmap api key for localhost:3000 - remember to change this!
   @gmap.api_key = "ABQIAAAArjtwNyA-0TDmcb74hMzhHBTJQa0g3IQ9GZqIMmInSLzwtGDKaBRSDWK-cqMmi3YB5dD-8a6Kwe1Qmg"

   @gmap.lat = 51.775362610
   @gmap.lng = -0.00100011
   @gmap.name = 'gmap'
   @gmap.zoom = 12
   
  end
  
end



The layout file: map.rhtml

In the html head

<%= yield :map_headers %> 



Within the body:

body onload="<%= @gmap.onload_func_name %>()" onunload="GUnload"  
    <%= yield %>




The view: index.rhtml

<% content_for :map_headers do %>
    <%= map_header(@gmap) %>
    <%= map_body(@gmap) %>
<% end %>

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | Back in time (1 older version) | Last edited by: scott, 4 months ago