Friday, July 29, 2011

Google Maps using Drupal

Adding a Google map to Drupal's contact form

1.Download and install the GMap module.

2.Go to your modules page and enable the "Contact" and "GMap" modules.

3.Request a Google Maps API key, enter it on your GMap page and click on the "Save configuration" button.

4.Go to your input formats page and select "Full HTML" as default input format. Configure the "Full HTML" input format, select "GMap filter" and click on the "Save configuration" button.

5.Use the online GMap macro builder to design your map and copy the generated macro text to the clipboard.

6.Go to your contact form settings page, paste the macro into the "Additional information" field and click on the "Save configuration" button.

7.Open the "template.php" file of your theme in your favorite editor and add the following function (also explained here):

function theme_contact_mail_page($form){
  $output = check_markup(variable_get('contact_form_information',
    t('You can leave a message using the contact form below.'))); 
  $output .= drupal_render($form);
  return $output;

8.That's it! Visit your contact page to verify that the Google map is displayed correctly.


  1. Can you please tell me where will i find "input format" (referring to point 4) in drupal 7

    1. You can find the "Input Format" below the body field in each of the drupal node.

  2. This comment has been removed by the author.