Matt is currently available for hire

Maptastic

A simple location selection input for Formtastic.

If you’ve spent time with Rails, you’ll already know that Formtastic is ace, and constructing forms using the SemanticFormBuilder keeps your code neat, and the output sensible and semantic.

More often, I find the need to include a control in my forms that allows the user to find and select a single LatLng, and, up until now, I’ve been adding in hidden fields and creating js that allows me to present a map control.

In an effort to reduce this duplication, I’ve built a Rails plugin for Formtastic that provides a new map_input and multi_input function, which means if you have a lat/lng pair, and you want to let the user fill out these values, all you need do is:

<% semantic_form_for @venue do |f| %>
  <%= f.multi_input :latitude, :longitude, :as => :map %>
<% end %>

Note you’ll also need to include the Google Maps script in your header:

<script type='text/javascript' src='http://maps.google.com/maps/api/js?sensor=true'></script>

Installation

You’ll need Formtastic

Install Maptastic as a plugin:

script/plugin install http://github.com/MattHall/maptastic

Or as a gem:

gem install maptastic-form

Development

This plugin is under development. It’s pretty simple, and patches are very welcome.

The Repo is available on GitHub.