Google Maps in Drupal with the GMap Module

drupal gmap

Several times in the last few weeks, OSTraining students have asked us about maps in Drupal.

The students wanted to set up directories that would show Google maps for each location.

They also wanted to create larger maps that would display multiple locations at once.

We recommended that the students use the GMap module. However, although that module is powerful, it is poorly documented and can be confusing to use.

So, here’s a beginners guide to the GMap module.

Adding a Location Field to Content

We need two key modules to make our maps work. Install and enable both of those modules:

After installing and enabling them, enable the Location CCK module too.

Now we need to select Google Maps for our maps.

  • Go to Configuration > Content authoring > Location > Geocoding Settings.
  • Select Google Maps for all the countries in which you want to list locations.
  • Go to Structure > Content types > Manage fields
  • Add an “Location” field to your content type:
  • On the field settings, choose what options you want to collect for each location:
  • Save the field.
  • Click the Manage Display tab
  • Choose a format for your field that will show the map. “Address with map” is a good choice.
  • Click “Add content”
  • Create a new content, including entering the address:

If everything has worked correctly, your content will appear with the map automatically generated, as in the image below.

We found a lot of people on the Drupal forums had problems with this step. They could manually enter their latitude and longitude settings, but GMap wouldn’t generate them automatically. If you have this problem, you’re not alone, and there are several possible solutions on the Drupal forums.

Controlling the Layout of Maps

By default, GMap provides a very small default map, but it also provides a great tool to solve that problem.

GMap has a “Build a GMap macro” option will allows you to design your map display:

  • The image below shows the macro that GMap will create for you. Copy the macro that you create.
  • Go to Structure > Content types > Manage fields > Edit your Location fields.
  • Paste your new macro into the field settings:

Creating the Large Map

Before you move onto creating the large map, make sure you have created more than one content item that uses your location field, otherwise you won’t be able to see if this large map is working.

  • Go to Structure > Views > Add new view
  • Choose your view settings, but make sure to choose “GMap” for Display format:
  • Click Continue & edit
  • Click Settings next to GMap
  • Enter a macro for a large map:
  • Save your view and your markers will show on your map.

There is much more that can be done with GMap, including adding tooltips for each marker, but hopefully this beginners guide is enough to get you up and running.


  • Steve Burge

    Steve is the founder of OSTraining. Originally from the UK, he now lives in Sarasota in the USA. Steve's work straddles the line between teaching and web development.

0 0 votes
Article Rating
Notify of

Newest Most Voted
Inline Feedbacks
View all comments
Harini Hari
Harini Hari
9 years ago

great website and it is very helpful for us

[url=]FUNNY HAPPY NEW YEAR 2015[/url]

9 years ago

nice blog about cloud enablementCloud Service Providers | Cloud Application Development Service | TechTrendsIT

8 years ago

Awesome info…

Hamed Azizi
Hamed Azizi
8 years ago

after set in manage display to “Address with map” and make content, don’t show map in node.

7 years ago
Reply to  Hamed Azizi

Me to, do you get an error that looks a little something like this?

Notice: Undefined property: stdClass::$data in google_geocode_location() (line 97 of /Library/Tenon/WebServer/WebSites/[url=]…[/url].

Notice: Trying to get property of non-object in google_geocode_location() (line 99 of /Library/Tenon/WebServer/WebSites/[url=]…[/url].

Notice: Trying to get property of non-object in google_geocode_location() (line 105 of /Library/Tenon/WebServer/WebSites/[url=]…[/url].

7 years ago
Reply to  Ryan Johnson

Hi Ryan,
That indicates your site is missing a library.


8 years ago

Hello, Thanks for the tutorial. Im missing the first bit though – which features should I enable under the 2 modules? I checked only the basic ones, but now I have a “Location” field added automatically to every node, and I cant change the field settings. I can add another Location field, but then I will have 2 Location fields. Besides, I would like to use the location only with one content type, not with all of them. Thanks

8 years ago
Reply to  Attila

Hi Attila,
Only the main modules themselves and “Location CCK” need to be enabled. We’ve added a note about “Location CCK” to the blog post.

8 years ago

hey Steve,

Thanks for the tutorial

I have three fields lat, long and value in the database and I want to create

maps populating data from this table with color coding on the basis of

values and thus creating labels too. This website does so probably using

leaflet [url=][/url]

Can you tell how to achieve such functionality ?

Would love your thoughts, please comment.x