- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在使用谷歌地图 API 来检查用户添加的地址,方法是传递邮政编码并返回一个格式化的地址,我可以比较该地址是否匹配。这是调用:
resultNodeList = (NodeList) xpath.evaluate("/GeocodeResponse/result/formatted_address", geocoderResultDocument, XPathConstants.NODESET)
问题是某些邮政编码可能是多个城市/城镇的一部分。以下是邮政编码 77380 的 google api 的结果:
<GeocodeResponse>
<status>OK</status>
<result>
<type>postal_code</type>
<formatted_address>Spring, TX 77380, USA</formatted_address>
<address_component>
<long_name>77380</long_name>
<short_name>77380</short_name>
<type>postal_code</type>
</address_component>
<address_component>
<long_name>Spring</long_name>
<short_name>Spring</short_name>
<type>locality</type>
<type>political</type>
</address_component>
<address_component>
<long_name>Texas</long_name>
<short_name>TX</short_name>
<type>administrative_area_level_1</type>
<type>political</type>
</address_component>
<address_component>
<long_name>United States</long_name>
<short_name>US</short_name>
<type>country</type>
<type>political</type>
</address_component>
<geometry>...</geometry>
<postcode_locality>Shenandoah</postcode_locality>
<postcode_locality>Spring</postcode_locality>
<postcode_locality>The Woodlands</postcode_locality>
<place_id>ChIJUXEWvwI0R4YRWJe_Gb6C8Bk</place_id>
</result>
</GeocodeResponse>
此示例中的用户居住在德克萨斯州伍德兰兹,而不是德克萨斯州斯普林。我现在想做的是拉入邮政编码位置,以便我可以比较列出的任何城市/城镇(Shenandoah、Spring、The Woodlands)
我厌倦了这样做:
resultNodeList = (NodeList) xpath.evaluate("/GeocodeResponse/result/postcode_locality", geocoderResultDocument, XPathConstants.NODESET);
但我只回到了 Shenandoah。我可以执行/GeocodeResponse/result/postcode_locality[1] 并手动获取每个位置,但此代码需要适用于输入的任何邮政编码。
有没有办法拉入邮政编码地点列表?
最佳答案
尝试使用以下内容:
Element e = (Element) node;
NodeList resultNodeList = e.getElementsByTagName("postcode_locality");
这可能对你有帮助。
关于java - 尝试使用 google api 获取所有城市/城镇的邮政编码时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35299465/
是否可以获得维基百科上所有有关系的国家、地区和城市的列表?我找不到任何适合此任务的 API。解析我需要的所有信息的最简单方法是什么?PS:我知道,我可以从其他数据源获取此信息。但我对维基百科感兴趣..
我有一个表“位置”,其结构如下 CREATE TABLE IF NOT EXISTS `locations` ( `id` int(11) NOT NULL, `city_code` int(11
我正在使用地点选择器的 Intent 来获取地点。现在我想将地址以国家、城市、密码、州的形式保存。我怎样才能从地点选择器的地址得到所有这些? 代码: public class NameOfBusine
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 6 年前。
我需要在地理图上绘制一些数据。具体来说,我想强调数据来自的国家和州。 我的数据集是 Year Country State/City 0 2009 BGR Sofia 1
我正在寻找一个可以将用户的输入转换为具有特定规则的新输出的函数。 这条规则是: 第一个字母大写(例如:Paris) 如果字符串的每个单词之间包含两个破折号 (-),则对第二个单词的第一个字母应用大写(
总共可能最多有 1000 个字符串。这些应该硬编码还是存储在数据库中?这些内容经常被访问,因为每次用户想要注册或结帐商品时,他们都需要查看区域/郊区/省/国家/地区列表。 如果我有一堆枚举,我认为性能
我有像国家/州和城市这样的下拉列表。有什么办法可以等到人口下降后再继续进行吗?就像首先加载国家/地区,然后根据选择的国家/地区然后加载州/省,与城市相同...... function populate
我想使用 PHP 和 jQuery 执行以下操作 https://www.careerbuilder.com/share/register.aspx?sc_cmp1=JS_LoginASPX_RegN
我正在建立一个网站,其中将有很多公司及其业务列表,因此他们将有他们的地址、城市、州、邮政编码等。 我在这里找到了这个网站: http://jesseprice.com/mysql-city-state
如何使用单一选择器 Objective-C 来管理国家/州/城市的值(value)? 当我尝试它时,它会因索引更改而崩溃。它适用于城市城市和州,但与城市有关。哪个库会更好用? 查看下面的代码 - (v
关闭。这个问题是opinion-based 。目前不接受答案。 想要改进这个问题吗?更新问题,以便 editing this post 可以用事实和引文来回答它。 . 已关闭 8 年前。 Improv
已关闭。此问题旨在寻求有关书籍、工具、软件库等的建议。不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以
我有一张 homes 表,其中包含国家、城市、大陆字段。 当某些人搜索房屋时,如果他输入例如“rom”我想返回 罗马 (30) 罗马尼亚 (120) 我该怎么做? 编辑使用此处的搜索表单 http:/
我希望将 HTML5 地理定位功能集成到网站中。我遇到的问题是在选定的列表中获取最近的城市/城镇。该网站仅在一定数量的城镇和引用中受支持/营销,因此浏览器可以找到其位置并选择最近的城镇或城市。听起来很
我想做一个马来西亚州和城市的下拉列表。 这是我的初始页面:(test3.php) 当我选择KL时,我对该城市的期望输出如下: 当我选择雪兰莪时,我对该城市的预期输出如下: 状态数据 json ($st
我已经实现了一个仅使用整数类型的邻接矩阵图。(我在这里提到的所有内容都考虑 C++) 我正在实现另一个图表,该图表将使用我的旧实现方案接收顶点中的城市和边中的距离。我想知道这是一个好主意还是我应该使用
我正在寻找一些关于在星际争霸/帝国时代等游戏中寻找基础设施开发策略的论文。这些游戏的基本特征是: 连续时间(好吧 - 它可以分成 10 秒的周期,或类似的时间) 许多描述增长的变量(许多资源、建筑物级
我目前有 3 个表存储有关世界上所有主要城市、与这些国家对应的每个地区/州以及这些州/地区中的每个城市的信息。 现在我的数据库中还有大约 6 个其他表,例如需要完全相同的 5 列的用户或组织表:地址、
我正在使用 django 构建一个旅游网站。当用户输入目的地城市名称(或兴趣点,如黄石)时,我想进行 ajax 自动建议。问题是我如何获得建议数据库?有没有网络服务?最好它也能支持外国城市。非常感谢。
我是一名优秀的程序员,十分优秀!