Skip to content

Location data with Drupal

2 min read

One of the most popular features on MothersClick is our geo-mapping system for mothers’ groups—a mashup of Google maps and mommy groups (created with the organic groups module).

Now, I receive lots of email and questions about how we built such a system with Drupal and location module. The fact is, we didn’t—well, we did use Drupal, but we did not use location module. The module is a behemoth, it performs slowly, and isn’t too friendly when you have data outside the US. We didn’t use the GMap module either—we didn’t want nor need the bloat.

So at MothersClick, we started fresh. We wrote a module that added a location form to any node type we specified and also to users. We then used a database table to store this data that was similar to location module’s table structure. From there, we hooked this up to Google’s geocoding service to grab latitude and longitude coordinates for an address. We also added in an address verification layer that worked with Google to verify addresses as well.

The next step was to add in proximity search. Due to time constraints we couldn’t build a full geo-spatial index, so we opted to rely on a bit of math for proximity searches. While this isn’t super ideal, it does indeed work very well for us.

Add in a custom Google maps module that communicates via AJAX with our custom location module and voilá!

Yes that’s great, how can I have it on my site, you might ask, eh?

Well soon you can!

Mark and Allie at Advantage Labs, together with Brandon Bergren have released 2 brand new geo modules:

  • Geo -- a module that provides spatial indexing of location data. Why's this useful? Well for starters, it's the ideal way to perform proximity searches using bounding boxes and so forth, considerably more efficient than our previous math query, and scales to millions of location data points. This module will be able to tie into views module and provide Google map functionality.
  • Postal -- this is the module that works as a CCK field so you can collect address/location data from *any* node type. There are many use cases where you need address data but you don't need to do much more than collect it. This module makes it very easy to collect that data. But when those instances arise when you need to do something with this data, such as plot all the mom groups in the world on a map, this will hook into geo for building spatial indexes to do such cool stuff :-)

These 2 modules are the future of geo data in Drupal, and I’m proud to say, that MothersClick will be contributing to both of these modules, as we plan to migrate our custom location modules to these modules one day soon.


Related Posts

Members Public

The Future of Automotive Mobility will be Powered by Open Source Software

Automotive companies are shifting from bending metal to bending bits. Soon they will be offering software and services to complement their manufactured metal. In order to win in the market, they will need to embrace open-source software to build leverage and enhance their offering.

Members Public

How to Host Your Static Website on Amazon S3: Step-by-Step Guide

1. Login to your Amazon AWS account 2. Create a new hosted zone for your domain using Route 53 3. Copy the NS records for this zone to your domain provider (e.g., GoDaddy) 4. Edit your domain on your domain registrar (e.g., GoDaddy) by clicking Set Nameservers 5.

Members Public

Book Review: Drupal 7 Module Development

Well, it’s been a while my Drupal friends, almost 18 months… dusting off this old Drupal 6 blog and time to start posting again. And what better way to get started again than by talking about Drupal 7, by far the best release of Drupal. And with almost 7