Drupal Google Map Integration
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
if(stristr($_GET['address'],'2nd Floor, '))
{
$_GET['address'] = str_replace('2nd Floor, ', '',$_GET['address']);
}
if(stristr($_GET['address'], '124 Nature Park Way'))
{
$_GET['address']=str_replace('124 Nature Park Way', '', $_GET['address']);
}*/
echo('
//Address:'.$address[0].''.$address[1].', '.$address[2]."".$address[3].'");
}
function load() {
if (GBrowserIsCompatible()) {
var coder = new GClientGeocoder();
coder.getLatLng(''.str_replace('abc',',',$address[3]).'',Af);
}
}
//]]>
');
?>
//
-->
-->