How can I convert UK postal codes into a Gpoint for google mapping? I am going around in circles on this one Jamie EDIT - JUST FOUND SOME GEO CODERS but anyone who has any tips, I am sure I will soon be out of my depth
Oh well no help so far - I have done the above, now I have a data base of let and longs, a web page with the map on it, now How do I get the data from the data base and add it to the map dynamically??
You should start by creating a map with just one point on it and learning about the map API. Once you have done this you just need to use PHP to loop through the results and output the required code.
use a service like www.postcodeanywhere.co.uk to convert your postcodes to latitude and lontitude on the fly. store the lat and long from the postcodes in a database so you don't need to look them up each time. Use the lat and long to make your gmap. Is what I use with postcode anywhere: global $ACCOUNTCODE,$LICENSEKEY; $ACCOUNTCODE = "xxxxxxxxxxxxxxx"; $LICENSEKEY = "xxxxxxxxxxxxxxxxx"; $OriginPostcode=$_GET['p']; // look up // is this postcode already recorded? $checkcode=str_replace(' ','',$OriginPostcode); $sql="select lat, lon from coords where postcode='".mysql_real_escape_string($checkcode)."'"; // echo $sql; $result=mysql_query($sql,$db); if (mysql_num_rows($result)==0) { // postcode not already in db, look up // get the postcode $sURL = "http://services.postcodeanywhere.co.uk/recordset.aspx?"; $sURL .= "account_code=" . urlencode($ACCOUNTCODE); $sURL .= "&license_code=" . urlencode($LICENSEKEY); $sURL .= "&action=nearest"; $sURL .= "&origin=" . urlencode($checkcode); $sURL .= "&destination=" . urlencode($checkcode); $ContentsXXX=file("$sURL"); foreach ($ContentsXXX as $line_num => $line) { if (strpos($line,"<z:row")!==false) { $Contents[]= $line; } } for ($i=0;$i<count($Contents);$i++) { $Contents[$i]=ltrim(rtrim($Contents[$i])); $Contents[$i]=str_replace("\"","",$Contents[$i]); $breakapart=explode(" ",$Contents[$i]); // convert the results into $variables foreach ($breakapart as $value){ list($k,$v)=explode("=",$value); ${$k}=$v; } // end foreach } // end look up // store the results in the db $sql="insert into coords (postcode,lat,lon) values ('$checkcode','$latitude','$longitude')"; // echo $sql; mysql_query($sql,$db); } else { // postcode was found in mapping database $data=mysql_fetch_array($result); $latitude=$data['lat']; $longitude=$data['long']; // echo $latitude; } Code (markup):