8

对英国邮政编码进行地理编码的最有效和最准确的方法是什么?使用内置的地理编码对象会导致结果非常模糊(许多邮政编码只返回一个一般区域)。

我可以通过 JavaScript 插入任何免费的英国邮政编码地理编码服务吗?

4

2 回答 2

7

编辑:为了更清楚,这使用谷歌搜索 api 中的本地搜索,而不是谷歌地图 api 来进行更准确的地理编码。

最好的方法是使用 Google Search Api。

如果您获得 api 密钥并进行所有设置:http ://code.google.com/apis/ajaxsearch/

var localSearch;
var map;
var icon;
var addressMarkerOptions;
google.load("search", "1");
google.load("maps", "2");
google.setOnLoadCallback(initialize);

function initialize()
{
  localSearch = new GlocalSearch();
  icon = new GIcon(G_DEFAULT_ICON);
  addressMarkerOptions = { icon:icon , draggable: false};
  map = new GMap2(document.getElementById("map"));
  map.addControl(new GLargeMapControl());
  map.addControl(new GMapTypeControl());
  plotAddress("OX4 1FJ");
}

/**
* This takes either a postcode or an address string
*
*/
function plotAddress(address)
{
  localSearch.setSearchCompleteCallback(null, 
    function() {

      if (localSearch.results[0])
      {     
        var resultLat = localSearch.results[0].lat;
        var resultLng = localSearch.results[0].lng;
        var point = new GLatLng(resultLat,resultLng);
        var marker = new GMarker(point, addressMarkerOptions);
        map.addOverlay(marker);
        map.setCenter(point, 5, G_NORMAL_MAP);
      }
      else
      {
        alert('address not found');
      }
    });

  localSearch.execute(address + ", UK");
}
于 2010-05-14T09:27:58.373 回答
-1

我相信 Live/Bing/Windows 地图的 API 为英国邮政编码提供了比 Google 地图 API 更准确的位置。

Alternatively, there are databases of UK postcode data available, although they're quite costly. There are some interesting comments on this post: http://jamiethompson.co.uk/web/2008/07/24/full-uk-postcode-database-for-free/

于 2010-05-14T09:37:48.897 回答