正确的地址格式可从 google GeoCoding API 获得最准确的结果

发布于 2024-12-09 16:24:24 字数 362 浏览 0 评论 0原文

是否有任何标准格式可以向 Google GeoCoding API 提供地址字符串,以获得地图上最准确的结果。

对于例如。以下查询未给出正确的结果。

http://maps /xml?address=bloom,Bloomfield,CT,06002,USA&sensor=false

谢谢曼迪普

.googleapis.com/maps/api/ geocode

Is there any standard format to supply the address string to Google GeoCoding API to get the most accurate results on map.

For Eg. following query not giving correct result.

http://maps.googleapis.com/maps/api/geocode/xml?address=bloom,Bloomfield,CT,06002,USA&sensor=false

Thanks

Mandeep

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

雨夜星沙 2024-12-16 16:24:24

我相信建议的格式是:

House Number, Street Direction, Street Name, Street Suffix, City, State, Zip, Country

显然,您可以提供的信息越少,结果就越不具体。

在您的示例中,地理编码器正在搜索名为“bloom”的街道,其中在 OH 而不是 CT 中有类似的匹配项。从查询中删除“bloom”,然后搜索将返回 Bloomfield, CT。

I believe the suggested format is:

House Number, Street Direction, Street Name, Street Suffix, City, State, Zip, Country

The results get less specific the less information you can supply, obviously.

In your sample, the geocoder is searching for a street named 'bloom', of which there are similar matches in OH instead of CT. Removing 'bloom' from the query and then searching returns Bloomfield, CT.

路还长,别太狂 2024-12-16 16:24:24

Google 地址搜索的定义:

地址 - 您要进行地理编码的街道地址,采用相关国家/地区的国家邮政服务使用的格式。应避免使用其他地址元素,例如企业名称和单位、套房或楼层号码。

https://developers.google.com/maps/documentation/geocoding/#geocoding

我应该如何格式化地理编码器查询以最大限度地增加成功请求的数量?

地理编码器旨在将街道地址映射到地理坐标。因此,我们建议您按照以下准则设置地理编码器请求的格式,以最大程度地提高查询成功的可能性:

  • 按照相关国家/地区的国家邮政服务使用的格式指定地址。
  • 请勿指定相关国家/地区邮政服务定义的地址中未包含的其他地址元素,例如企业名称、单元号码、楼层号码或套房号码。
  • 尽可能优先使用房屋的街道号码而不是建筑物名称。
  • 在可能的情况下,优先使用街道号码寻址而不是指定交叉街道。
  • 不要提供“提示”,例如附近的地标。

https://developers.google.com/maps/faq#geocoder_queryformat

Definition of Google address search:

address - The street address that you want to geocode, in the format used by the national postal service of the country concerned. Additional address elements such as business names and unit, suite or floor numbers should be avoided.

https://developers.google.com/maps/documentation/geocoding/#geocoding

How should I format my geocoder queries to maximise the number of successful requests?

The geocoder is designed to map street addresses to geographical coordinates. We therefore recommend that you format geocoder requests in accordance with the following guidelines to maximise the likelihood of a successful query:

  • Specify addresses in accordance with the format used by the national postal service of the country concerned.
  • Do not specify additional address elements such as business names, unit numbers, floor numbers, or suite numbers that are not included in the address as defined by the postal service of the country concerned.
  • Use the street number of a premise in preference to the building name where possible.
  • Use street number addressing in preference to specifying cross streets where possible.
  • Do not provide 'hints' such as nearby landmarks.

https://developers.google.com/maps/faq#geocoder_queryformat

森林迷了鹿 2024-12-16 16:24:24

我发现答案不完整并且缺乏来源。

请查看此处:https://developers.google.com/places/documentation/autocomplete#place_autocomplete_responses< /a>

谷歌的地图自动完成 API 返回一个更简单的格式:“街道地址、城市、国家”
现在您可以使用这样的字符串来搜索地址,它应该会产生一个准确的结果。
此外,如果您使用自动完成 API,您还将获得一个唯一标识符,可用于进一步的详细请求。

街道地址的格式很大程度上取决于您实际所在的位置。
在美国“门牌号、街道方向、街道名称、街道后缀”可能有意义,在欧洲大部分地区它不会导致成功的查询。

欧盟大部分地区的地址都不同(通常是“街道名称后缀”),例如“Kumpelstraat 25A”、“Psolevcu 331/26b”),我想如果我们看看一些东方国家,我们会感到惊讶。

因此,如果您将代码绑定到单个区域(美国、欧盟大部分地区),您可能会很好地对格式进行硬编码。
如果您想拥有一个更灵活的系统,您要么需要为您的目标受众找出正确的格式,要么查询谷歌 API 之一以自动获取正确的字符串。
我链接的那个非常好,但需要一个 API 密钥,每天有免费请求限制。

I found the answer incomplete and it lacked a source.

Look here: https://developers.google.com/places/documentation/autocomplete#place_autocomplete_responses

The maps autocompletion API from google returns a much simpler format: "Street address, City, Country"
Now you can use a string like that to search for an address and it should lead to one exact result.
In addition if you use the autocompletion API you will get a unique identifier too which can be used for further detail requests.

The format of the street address greatly depends on the location where you actually are.
In the US "House number, street direction, street name, street suffix" might make sense, in most of Europe it will not lead to successful query.

Addresses in most of EU are different (often "Streetname number suffix") like "Kumpelstraat 25A","Psolevcu 331/26b") and I guess we'd be surprised if we look at some eastern countries.

So if you bind your code to a single area (US, most of EU) you might be good hardcoding the format.
If you want to have a more flexible system you either need to find out propper formating for your target audience or query one of googles APIs to automatically get a proper string.
The one I linked is very good but requires an API key with a free request limit per day.

乱世争霸 2024-12-16 16:24:24

我偶然发现了这个问题,找到了一个对我有用的解决方案:

我认为可以通过使用组件过滤找到答案,看看:
https://developers.google.com/maps/documentation/geocoding/#ComponentFiltering

Javascript 中的示例:

var request = require('request');

var url = "https://maps.googleapis.com/maps/api/geocode/json?" +
    "address=Herengracht 180" +
    "&components=postal_code:1016 BR|country:NL" +
    "&sensor=false";

request(url, function (error, response, body) {
  if (!error && response.statusCode == 200) {
    console.log(body);
  }
  else {
    console.log('error', error);
  }
});

I stumbled upon this question and found a solution that worked for me:

I think the answer can be found by using component filtering, look at:
https://developers.google.com/maps/documentation/geocoding/#ComponentFiltering

An example in Javascript:

var request = require('request');

var url = "https://maps.googleapis.com/maps/api/geocode/json?" +
    "address=Herengracht 180" +
    "&components=postal_code:1016 BR|country:NL" +
    "&sensor=false";

request(url, function (error, response, body) {
  if (!error && response.statusCode == 200) {
    console.log(body);
  }
  else {
    console.log('error', error);
  }
});
多彩岁月 2024-12-16 16:24:24

无需避开公寓单位。此方法有效:

https: //maps.googleapis.com/maps/api/geocode/xml?address=14202+N+42nd+St+Unit+301+33613

“Apt”、“Room”和“Suite”也可以工作。

它们都返回 301 作为子前提,并在“formatted_address”中显示为“#301”。

保罗送...

No need to avoid apartment units. This works:

https://maps.googleapis.com/maps/api/geocode/xml?address=14202+N+42nd+St+Unit+301+33613

"Apt", "Room", and "Suite" work as well

They all return 301 as subpremise and are shown in "formatted_address" as "#301."

Paul sends...

孤独难免 2024-12-16 16:24:24

我发现“US”、“DE”、“FR”等官方国家代码效果不佳。用完整的国家/地区名称替换它们会给我带来更好的结果。

我没有找到这样的来源。

I found that official country codes like "US", "DE", "FR" do not work well. Replacing them with the full country name gives much better results for me.

I did not find a source where that is stated.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文