开发者

How can I take a text query, and get a location in Android?

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: T开发者_如何学Co 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜