3

I have an existing Drupal 5 site that I want to port over to Drupal 7. In my existing site, I have custom CCK types for, for example, a business type such as restaurants. I have the Location and GMap modules enabled. When entering a new restaurant, I type in the address of the restaurant and it is geocoded and the node type displays a map.

Now in Drupal 7 I'm trying to figure out how to do the same thing. I know CCK got partly rolled into Drupal 7. Which modules should I use for entering in the address info? I looked at the Location and GMap modules but they're both currently in dev only and I don't want to run development modules on my production site. So what's the drupal 7 way to handle address info, geocode it, and display a google map?

2

I found this blog post which looks promising: Placing Users on a Map in Drupal 7 - with Openlayers, Addressfield and Geocoding

It says to use a combination of: Addressfield Geofield Geocode Openlayers

Except geocode doesn't seem to have an official 7 release

UPDATE

I successfully got this working, using this blog post as a foundation. The article is talking about adding map data to user profiles. In my case, I wanted to add map data to content nodes so I didn't need the Profile stuff. I used the following modules (and their dependencies):

Yes, some of these are dev modules which is not ideal, but it seemed unavoidable to get the functionality I wanted.

In the article he talks about using his own fork of the Geocode module, but I found using the Geocoder (note the "er" ending) module (as suggested by the geofield module) instead worked fine.

Overview

In a nutshell this solution uses Address field to hold the address data and geofield to hold the coordinate data and OpenLayers to display the map. The geocoder module is the glue between the address data and the empty geofield, taking the address data and populating the geofield. The OpenLayers module uses the geofield coordinates to display the map.

Steps

I created a "Map" in OpenLayers which is basically like a preset of how you want the map to look and behave (e.g, map type, zoom level, etc). This takes some tweaking to get things setup the way you want them.

Then I added a content type xyz. In that content type I clicked "Manage Fields" and added an address field (Postal address). Then I added a Geofield, and in the widget drop down I chose "Geocode from another field". In the settings for the field I was able to choose the Address field I created earlier as the source.

Then in the "Manage Display" section of my xyz content type, for my geofield I chose "OpenLayers" from the Format drop down list. And in the configuration of that field I chose the OpenLayers map type I had created earlier.

One thing I'm not crazy about is with the OpenLayers module; I can't seem to get the normal Google Maps pan and zoom controls and instead get some somewhat funky looking pan/zoom controls.

UPDATE

Apparently you can customize the pan and zoom controls using any images you like via css. This blog post discusses it at the end: Take Control of Your Maps

1

I've used the Geolocation module successfully. It provides a widget for entry of the location and a formatter for display as a map.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.