如何在 Android 中进行文本查询并获取位置?
我想知道如何在用户输入文本位置(例如餐厅名称和城市名称)的意义上引导或模拟 Google 地图。然后 Google 建议他们已索引的 5 个左右的地点,并且大概他们知道 GPS 坐标,因为 Google 然后将它们放在地图上。我希望能够使用该功能 - 不是地图,只是获取位置。
我的目标是让用户输入查询,显示 5 个左右的选项,如果用户选择其中之一,则保存表示该地点的 GPS 坐标或位置对象。
理想情况下,我可以将查询发送到 Google 并将结果窃取回我的应用程序。显然,建立我自己的位置数据库和建议它们的算法是不可能的。
感谢您提前的帮助和建议!
注 1:澄清一下,这不涉及用户/设备的当前位置。
注 2:我查看了 Google 地图附加 API,但它看起来像是用于可视化地图,而不是查询位置部分。你应该已经知道你的位置,它会绘制出它的地图。
I was wondering how I can channel or simulate Google Maps just in the sense of a user types in a location in text, such as a restaurant name and a city name. Then Google suggests 5 or so places they have indexed, and presumably they know the GPS coordinates because Google then puts them on a map. I want to be able to use that feature- not the map, just getting the location.
My goal is for a user to type in a query, 5 options or so to be shown, and if they user chooses one of them, then the GPS coordinates, or a location object, is saved representing that place.
Ideally I could just send the query to Google and steal the results back to my app. Obviously building my own database of locations and an algorithm to suggest them is out of the question.
Thanks for the help and advice in advanced!
Note 1: To clarify, this does NOT involve the current position of the user/device.
Note 2: I looked at the Google Maps add-on API, but it looks like that is for a visual map, not the querying a location part. You are already supposed to know your location, and it will map it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 geocoder.getFromLocationName,您将返回一个 Address 对象列表,在这些对象中您将找到有关该位置所需的所有信息。
要在模拟器上测试此功能,您需要包含 Google API 的图像。如果您安装了市场,则在设备中应该没问题。
Use geocoder.getFromLocationName, you get back a list of Address objects, in those objects you will find all the information you need about the location.
To test this on the simulator you need an image with the Google APIs included. In a device should be fine if you have the market installed.