Drupal Google Map Issue (without location module)

0 Comments

I posted a blog post about Drupal Google Map integration a few weeks ago. In that posting, I mentioned that Google Maps can be integrated by simply creating a custom .php page which embeds the Google Map API JavaScript inside it and then fetch the right Google Map based on the URL ($_GET variable).

I think that while this method works for most sites, this may not work for a lot of directory sites simply because people enter non conventional addresses. In order to prevent this from happening, there are 2 things that can be done:
1) Let people enter the longtitude and latitude of their address
2) Let people upload an image of the map if the mapping does not work

However, as in most sites that have user generated content, there will be people who would not know what they are doing and enter something weird into the address field.

Drupal Google Map Integration (simple integration)

0 Comments

There are currently numerous ways for integrating Google Maps with Drupal. The most popular method is to use the GMap Module together with the Location module. This method provides the most functionality and highest level of customization. However for relatively simple integrations, it is possible to simply embed the javaScript as part of a custom module or part of a custom page. This will allow for a simple JavaScript integration which makes use of the Google Geo Coder API.

Basically, the idea is to supply the Address string to the google geo coder which returns the longtitude and latitude of the site. This will enable Google map to pin point that address.

The following is some sample code that we have altered from a contribution at Drupal.org:

Google Maps JavaScript API Example

<?php
$address = explode('abc', $_GET['address']);
#hacked by api for Robert Armstrongs map. may need to replace this with a preg_replace for other ppl
/*if(stristr($_GET['address'],'South Tower'))
{
$_GET['address'] = str_replace(', South Tower','', $_GET['address']);
}
#hacked by api for Mitchell D. Childs map. this is gotta be the ugliest way of doing things