1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Google maps UK geocode

Discussion in 'Google API' started by stuw, Jan 31, 2006.

  1. #1
    I'm not sure if I should have posted this under programming - but most google map posts seem to be here.

    I need to be able to generate a Google Map using a UK postcode.

    Does anyone know of a UK geocode resource that will help me convert / find the lat and long values I need to pass to GM?
     
    stuw, Jan 31, 2006 IP
  2. stuw

    stuw Peon

    Messages:
    702
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #2
    yes, thank you red repper for suggesting "google it" - I did for half an hour before posting here. Get a life.
     
    stuw, Feb 1, 2006 IP
  3. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #3
    T0PS3O, Feb 1, 2006 IP
  4. dave487

    dave487 Peon

    Messages:
    701
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #4
    We have a huge amount of google maps on our site and all the postcode lookups are done with postcodeanywhere.

    I have a php script if anyone wants it.
     
    dave487, Feb 1, 2006 IP
  5. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I'd like to see those maps of yours. I studied GIS and am a sucker for internet maps.
     
    T0PS3O, Feb 1, 2006 IP
  6. stuw

    stuw Peon

    Messages:
    702
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I forgot to mention that dave487 came to the rescue.

    I had found postcodeanywhere.co.uk whilst googling around, but had missed the key thing I was looking for - a per conversion rate. Not an annual fee. Thanks for pointing that out.

    I also found jibble - but it seemed too vague for what I wanted to use it for.
     
    stuw, Feb 1, 2006 IP
  7. dave487

    dave487 Peon

    Messages:
    701
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #7
    dave487, Feb 1, 2006 IP
  8. stuw

    stuw Peon

    Messages:
    702
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I can't seem to find a way to get the co-ordinates for google maps from a postcode without a double hit using postcodeanywhere.

    It seems to get the lat / long I need to pass a location id, and I need to get the location id from passing a postcode?

    If you could pm your code, or post the method you use that would be a great help. Appreciate your time on this.

    Stuw
     
    stuw, Feb 1, 2006 IP
  9. dave487

    dave487 Peon

    Messages:
    701
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #9
    
    global $ACCOUNTCODE,$LICENSEKEY;
    $ACCOUNTCODE = "xxxxxxxxx";
    $LICENSEKEY = "yyyyyyyyyyyy";
    
    $OriginPostcode = @$_GET['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($OriginPostcode);
    $sURL .= "&destination=" . urlencode($OriginPostcode);
    $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
     
      // coordinates are now saved as Easting: $grid_east_m and 
    //Northing: $grid_north_m and $latitude $longitude
    
    PHP:
    This passes a postcode to postcodeanywhere and returns the coordinates. To use this in a find nearest script you need a database on your server with all your locations stored with their lat,long,easting and northing (email an excel file of your locations to postcode anywhere and they will populate these values for you).

    Let me know if you need a script to sort the results by distance.......
     
    dave487, Feb 2, 2006 IP
    stuw likes this.
  10. stuw

    stuw Peon

    Messages:
    702
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Awesome Dave, thanks. I'll have a play with that later.
     
    stuw, Feb 2, 2006 IP
  11. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #11
    4p sounds expensive. I enquired before for acquiring such a database and it's about 200 quid. That way you don't rely on any 3d parties, own the software and don't get bills when your application gets popular.

    If you stick to postcode outcode (the first part) you only need about 1800 records so the database is fairly small and inexpensive.
     
    T0PS3O, Feb 3, 2006 IP
  12. dave487

    dave487 Peon

    Messages:
    701
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #12
    The problem is that postcodes change all the time. I recently moved to a newly built house and trying to arrange all the insurance & utilities was a nightmare as every website and call centre will only help people with a valid postcode.
    I had to wait weeks in some cases for their postcode databases to update before they could help me (I had to contact Royal Mail to ask them to update the database).

    So I would be very annoyed if a site did not have my postcode and a search script failed bacause of it.

    Also you need exact lats and longs to pinpoint the locations to put on a map - this is not available if you only use the outcode bit.

    Credits are cheaper in bulk - 65,000 cost £1k which is 1.5p each.
     
    dave487, Feb 3, 2006 IP
  13. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #13
    True, for mapping outcode isn't accurate, but for 'nearest' queries it's OK. And yes, with a service you don't have to piss about yourself with the updated.

    1.5p is more like it. In that case and based on the arguments you gave, it's a good deal indeed.

    I got a sample of the Royal Mail themselves, the PAF data. That's both a rip-off AND a nightmare. Don't do there, let others do that for you.
     
    T0PS3O, Feb 3, 2006 IP
  14. masheruper

    masheruper Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    You might also want to try iShareMaps. They have a decent postcode geocoder. see www.geocode.isharemaps.com
     
    masheruper, May 4, 2006 IP
  15. trytomakeitbig

    trytomakeitbig Guest

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    ..did you decide on?

    I'm just about to embark on my own (and first) project and also need to use geomapping but can't find full postcode / lat long tables, unless paying.

    Hence your advice would be much appreciated..

    Thanks
     
    trytomakeitbig, Sep 11, 2006 IP
  16. walweb

    walweb Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #16
    Showing satellitepictures at streetlevel of a UK postcode, try "Picsfromspace, lookup your place by address" at "http://www.walweb.nl/picsfromspace"
     
    walweb, Oct 12, 2006 IP
  17. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #17
    Resurrecting this because I found the definitive answer and this threads ranks first page Google for relevant terms.

    Emad Fanous is a fantastic person who bought a dedicated server and coded some great tools to do world wide geocoding for a variety of input data and allows a broad range of output options as well.

    He allows mass geocoding, yesterday I emailed him about doing 9000 UK postcodes to WSG-84 Lat/Lon coordinates and he said it was fine. He even added a plain text output option.

    In PHP all you have to do is this for each Postcode:

    
    $url = "http://geo.localsearchmaps.com/?zip=";
    			$url .= urlencode($post_code);
    			$url .= "&country=UK&use=google2&format=txt";
    			
    			if ($grab_coordinates = file_get_contents($url)) {
    				$coord_pair = explode(", ", $grab_coordinates);
    				
    				if (sizeof($coord_pair) == 2) {
    					// OK we've got what we need so chuck it in the DB!
    					$latitude = $coord_pair[0];
    					$longitude = $coord_pair[1];
    					$sql = "etc";
    				}
    				
    			}
    
    PHP:
    Read the linked blog post for other input options. Truly wicked and hopefully the Royal Mail will get done in for monopolizing their postcode data soon.
     
    T0PS3O, Dec 4, 2006 IP
  18. mattp

    mattp Guest

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #18
    I have written a tutorial on the free geocoding of UK postcodes, along with a PHP class, that you can read at http://www.mattpryor.co.uk/tutorials/show/1/
     
    mattp, May 2, 2007 IP
  19. dx_83

    dx_83 Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #19
    http://www.infosports.com/m/map.htm
     
    dx_83, May 15, 2007 IP
  20. inspireme

    inspireme Peon

    Messages:
    84
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #20
    I dont think your allowed to use google maps to mass geocode a database, its against the T&C, it used to be against the T&C to store the lat/lon in the database but i know they have made many changes and i believe that restriction was removed. I would like confirmation from google on that before using it but looks really interesting.

    Ona more positive note there has been some really amazing projects to make a public domain postcode list, PLEASE PLEASE contribute to this as it will be the end of all our problems! Its actually really useable allready, you jsut need to click the map and type your postcode. Add all postcodes you can think of and can locate on the map!

    http://www.npemap.org.uk/
     
    inspireme, Jun 14, 2007 IP