Reputation: 4044
This is for a search facility on a website. I have it all working using the standard Google Maps geocoder, but for some strange reason it seems to search only on the first part of a postcode.
It can be done in client-side JS using GlocalSearch. However, it isn't clear how to translate this into a server-side solution.
Here is a simplified version of what I have at the moment:
<?php
$requestURL = "http://maps.google.co.uk/maps/geo?output=csv&key=$apiKey&gl=uk&q="
. urlencode($_GET['pc']);
echo file_get_contents($requestURL);
?>
(Put your API key in to test.) Try, for example, DE1 2PQ and DE1 3NF. Exact same coordinates reported for both.
Any ideas?
Upvotes: 0
Views: 1830
Reputation: 4044
I found the answer in the end. Google provides access to the server-side scripts underlying the Ajax API for non-JS applications, so I just had to follow the instructions and reference on the Google site. Local Search is the one of relevance here.
Upvotes: 1
Reputation: 96167
The UK mapping data is expensive, it's possible that Google only have a licence to the higher level postcode data for the first part of the code (the overall area) and not the full street level position.
edit:
Or they might have a non-distributable licence to the exact data. But the large scale data is freely available.
And why you should have to pay the public owned post office for public data that would make their job easier is even less clear.
Upvotes: -1