OK mate this is what you need to do.
POST in the url the school address in the following format as seen in the link code here:
Code:
<a href="map.php?name=The Oval Primary School&address1=Whittington Oval&address2=&town=Birmingham&county=West Midlands&postcode=B33 8JG"><strong class="interactive_map">(Interactive Map)[/b]
This link will open the map.php page.
For this page i have done a hack the reads the lat and long off the google server from a postcode.
PHP Code:
<?
function geoCode($address) {
$gaddress = "http://maps.google.com?q=" . urlencode($address);
$handle = fopen($gaddress, "r");
$contents = '';
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
fclose($handle);
ereg('viewport: \{center: \{lat: ([0-9.-]{1,}),lng: ([0-9.-]{1,})', $contents, $regs);
$returnData['lat'] = $regs[1];
$returnData['lon'] = $regs[2];
return $returnData;
}
if(isset($_GET['lat']) && isset($_GET['lon'])){
$lat = $_GET['lat'];
$lon = $_GET['lon'];
}else{
$returnData=geoCode($_GET['postcode']);
$lat = $returnData['lat'];
$lon = $returnData['lon'];
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="keywords" content="" />
<meta name="description" content="">
<title>Virtual Earth / Google Maps - Map</title>
<style>
.clear {
clear:both;
height:1px;
line-height:1px;
}
#contact_back {
position: absolute;
width: 170px;
margin-top: 7px;
margin-left: 550px;
z-index: 1001;
background-color: #0040C4;
border: 1px solid #000000;
text-align: center;
height: 16px;
font-size: 1.1em;
text-decoration:none;
cursor:pointer;
cursor:pointer;
}
#contact_back a {
color:#000000;
text-decoration:none;
}
#contact_back a:hover {
color:#000000;
text-decoration:none;
}
</style>
<script src="http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js"></script>
</script>
<script>
var map = null;
var pinID = 1;
function GetMap(){
map = new VEMap('myMap');
map.LoadMap(new VELatLong(<?= $lat;?>, <?= $lon;?>), 12 ,'r' ,false);
}
function FindLoc(Loc){
map.FindLocation(Loc);
}
function GetInfo(){
alert('The top edge of the map on the Web page is at pixel: '+map.GetTop());
alert('The left edge of the map on the Web page is at pixel: '+map.GetLeft());
alert('The latitude,longitude at the center of the map is: '+map.GetCenter());
alert('The current zoom level of the map is: '+map.GetZoomLevel());
alert('The map control version is: '+VEMap.GetVersion());
}
function AddPin(){
var pin = new VEPushpin(
pinID,
map.GetCenter(),
"images/anchor_sm.jpg",//this is where you can use your own icon or pointer.
'<? echo (isset($_GET['name']) && $_GET['name']!="")?$_GET['name']:"";?>',
'<? echo (isset($_GET['address1']) && $_GET['address1']!="")?$_GET['address1']."
":"";?><? echo (isset($_GET['address2']) && $_GET['address2']!="")?$_GET['address2']."
":"";?><? echo (isset($_GET['town']) && $_GET['town']!="")?$_GET['town']."
":"";?><? echo (isset($_GET['county']) && $_GET['county']!="")?$_GET['county']."
":"";?><? echo (isset($_GET['postcode']) && $_GET['postcode']!="")?$_GET['postcode']."
":"";?>'
);
map.AddPushpin(pin);
pinID++;
}
</script>
</head>
<body onload="GetMap();AddPin()">
<div id="content_header"> <div id="header_space">Contact Us </div>
<div id="sub_header"> Interactive Map : </div>
<div class="style1" id="contact_back" onclick="javascript:history.back(1)">< Back to contacts page </div>
<div id='myMap' style="position:relative; width:750px; height:500px;"></div>
<div class="clear"> </div>
</div>
</body>
</html>
Let me know how you get on. 8)