Google 地图喜欢邮政地址的自动完成或自动建议 API

发布于 2024-09-26 03:24:40 字数 1539 浏览 7 评论 0原文

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

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

发布评论

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

评论(2

邮友 2024-10-03 03:24:41

您可以使用 google 地理自动完成 api

http://code.google.com/p/geo-autocomplete /

这将为您提供与谷歌地图上相同的位置自动完成功能。

You can use googles geo autocomplete api

http://code.google.com/p/geo-autocomplete/

This will give you the same auto-complete for locations that you would get on googlemaps.

淡淡の花香 2024-10-03 03:24:40

这看起来为您提供了一种与您正在寻找的解决方案类似的解决方案。如果您将 on_click 事件替换为 Javascript onkeyup 事件,您应该能够实时检查地址。

这是一个快速分步集成指南,描述如何将基于 RapidAddress 邮政编码的地址查找器添加到 HTML 网站。我们建议您首先阅读 JavaScript 用户指南。
步骤#1
从下载部分下载最新版本的 JavaScript 类。您还可以使用集成包,它包含现成的 HTML 页面,可以方便地作为起点。
将 JavaScript 文件 crafty_postcode.class.js 上传到您的网络服务器并在 HTML 中引用它,您可能必须在 src 属性中使用相对或绝对路径:

<script type="text/javascript" charset="ISO-8859-1" src="crafty_postcode.class.js">
</script>

注意:“ISO-8859-1”位很重要,因为 JS 脚本被压缩。
步骤#2
创建并配置 JavaScript 对象:

<script>
    var cp_obj = CraftyPostcodeCreate();
    cp_obj.set("access_token", "xxxxx-xxxxx-xxxxx-xxxxx"); // your token here
    cp_obj.set("result_elem_id", "crafty_postcode_result_display");
    cp_obj.set("form", "address");
    cp_obj.set("elem_company"  , "companyname");
    cp_obj.set("elem_street1"  , "address1");
    cp_obj.set("elem_street2"  , "address2");
    cp_obj.set("elem_street3"  , "address3");
    cp_obj.set("elem_town"     , "town");
    cp_obj.set("elem_county"   , "county");
    cp_obj.set("elem_postcode" , "postcode");
</script>

步骤#3
在 HTML 中创建地址表单:

<form method="post" name="address"> 
 Postcode:<br/>
 <input type="text" name="postcode"/>   
 <button type="button" onclick="cp_obj.doLookup()">Find Address</button><br/>
 <span id="crafty_postcode_result_display"> </span><br/>
 Company:<br/>
 <input type="text" name="companyname"/><br/>
 Address:<br/>
 <input type="text" name="address1"/><br/>
 <input type="text" name="address2"/><br/>
 <input type="text" name="address3"/><br/>
 Town:<br/>
 <input type="text" name="town"/><br/>
 County:<br/>
 <input type="text" name="county"/>
</form>

注意:“companyname”、“address2/3”和“county”是可选的,如果适合您的网站,您可以忽略这些字段。请记住在步骤 2 中从 JavaScript 配置中也删除它们。例如,如果您不需要县字段: cp_obj.set("elem_county", "");
请注意“查找地址”按钮,onclick 操作调用 doLookup() 方法。
地址结果(或错误消息)将放置在 id="crafty_postcode_result_display" 的元素中。
全部完成!
如果由于任何原因无法正常工作,请将任何错误代码/消息通过电子邮件发送给我们。我们将很乐意提供帮助。如果您还没有阅读过 JavaScript 用户指南,您可能还想阅读。

位于:

http:// /www.craftyclicks.co.uk/web-service/docs/javascript-address-finder-how-to-add-rapidaddress

This looks to give you a solution similar to the one you are searching for. If you replace the on_click event with the Javascript onkeyup you should then be able to check the address realtime.

This is a quick step-by-step integration guide describing how to add a RapidAddress postcode based address finder to a HTML website. We recommend you read the JavaScript user guide first.
Step #1
Download the latest version of the JavaScript class from the downloads section. You could also use the integration pack, it contains ready made HTML pages that may be handy as a starting point.
Upload the JavaScript file crafty_postcode.class.js to your webserver and reference it in your HTML, you may have to use relative or absolute paths in the src property:

<script type="text/javascript" charset="ISO-8859-1" src="crafty_postcode.class.js">
</script>

NOTE: the "ISO-8859-1" bit is important as the JS script is compressed.
Step #2
Create and configure the JavaScript object:

<script>
    var cp_obj = CraftyPostcodeCreate();
    cp_obj.set("access_token", "xxxxx-xxxxx-xxxxx-xxxxx"); // your token here
    cp_obj.set("result_elem_id", "crafty_postcode_result_display");
    cp_obj.set("form", "address");
    cp_obj.set("elem_company"  , "companyname");
    cp_obj.set("elem_street1"  , "address1");
    cp_obj.set("elem_street2"  , "address2");
    cp_obj.set("elem_street3"  , "address3");
    cp_obj.set("elem_town"     , "town");
    cp_obj.set("elem_county"   , "county");
    cp_obj.set("elem_postcode" , "postcode");
</script>

Step #3
Create an address form in HTML:

<form method="post" name="address"> 
 Postcode:<br/>
 <input type="text" name="postcode"/>   
 <button type="button" onclick="cp_obj.doLookup()">Find Address</button><br/>
 <span id="crafty_postcode_result_display"> </span><br/>
 Company:<br/>
 <input type="text" name="companyname"/><br/>
 Address:<br/>
 <input type="text" name="address1"/><br/>
 <input type="text" name="address2"/><br/>
 <input type="text" name="address3"/><br/>
 Town:<br/>
 <input type="text" name="town"/><br/>
 County:<br/>
 <input type="text" name="county"/>
</form>

NOTE: "companyname", "address2/3" and "county" are optional, you can leave these fields out if it suits your site. Remember to delete also them from the JavaScript config in step 2. For example if you do not want the county field : cp_obj.set("elem_county", "");
Note the 'Find Address' button, the onclick action calls the doLookup() method.
The address results (or an error message) will be placed in the element with id="crafty_postcode_result_display".
All done!
If things don't work for any reason, email any error codes/messages to us. We will be happy to help. You may also want to read the JavaScript user guide, if you haven't already.

As found at:

http://www.craftyclicks.co.uk/web-service/docs/javascript-address-finder-how-to-add-rapidaddress

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