使用 Google Maps API 对英国邮政编码进行地理编码的最佳方式?

问题描述 投票:0回答:3

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

是否有我可以通过 JavaScript 插入的免费英国邮政编码地理编码服务?

google-maps geocoding google-maps-api-2
3个回答
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");
}

0
投票

以下数据集可能是活动邮政编码最准确的方法:

https://www.ordnancesurvey.co.uk/products/code-point-open


-1
投票

我相信 Live/Bing/Windows 地图 API 可以比 Google 地图 API 更准确地定位英国邮政编码。

或者,也有可用的英国邮政编码数据数据库,尽管它们相当昂贵。这篇文章有一些有趣的评论:http://jamiethompson.co.uk/web/2008/07/24/full-uk-postcode-database-for-free/

© www.soinside.com 2019 - 2024. All rights reserved.