First, you'll need to install Formtastic.
Next, install Maptastic as a plugin:
script/plugin install git@github.com:MattHall/maptastic.git
...and run the rake task to install the required js file into your javascripts directory. You will probably need to include this in your layouts, too.
rake maptastic_form:install
You can alternatively install the gem:
gem install maptastic-form
Note if you're using the gem, then you'll need to copy the JS asset from:
https://github.com/MattHall/maptastic/blob/master/assets/javascripts/maptastic.js
You'll need to add the Google Maps V3 script include in your page, above your semantic_form:
<script type='text/javascript' src='http://maps.google.com/maps/api/js?sensor=true'></script>
Note that you no longer need an API key with the latest Google Maps release.
Maptastic adds a new #multi_input method as well as the map control:
<% semantic_form_for @venue do |f| %>
<%= f.multi_input :latitude, :longitude, :as => :map %>
<% end %>
Note that the map input expects two parameters - a latitude and longitude. The order is important.
This plugin is under development. It's pretty simple, and patches are very welcome.
The Repo is available on GitHub
A testbed app is available to check that the changes made actually work as expected.
Copyright © 2010 Matthew Hall, released under the MIT license.