有没有办法准确判断用户在使用Android位置管理器哪个城市在美国​​? [英] Is there a way to accurately determine which city in US the user is in using Android Location Manager?

查看:139
本文介绍了有没有办法准确判断用户在使用Android位置管理器哪个城市在美国​​?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图确定在美国的城市用户使用来自Android应用程序的当前位置。我想使用GPS的位置提供但如何准确地判断可以从城市或区域设置的名称,纬度/经度数据。

I am trying to determine the city in USA the user is in using their current location from an Android App. I want to use the GPS as the location provider but how accurately can I determine the name of the city from the Locale or Latitude / Longitude data.

比如我注意到了Twitter的应用程序来确定你是在曼哈顿曼哈顿啁啾的时候,但有可能从位置数据检索纽约市的曼哈顿,而不是也和洛杉矶,而不是比佛利山庄。

For instance I noticed the twitter app determines you are in Manhattan when tweeting from Manhattan, but is it possible to retrieve New York City instead of Manhattan from the location data and likewise Los Angeles instead of Beverly Hills.

这是因为所有我需要确定的是用户在按当前位置在哪个城市。

This is because all I need to determine is which city the user is in as per the current location.

感谢所有帮助。

推荐答案

您需要的地理codeR类。见参考,这是很容易使用:的http://开发商.android.com /参考/安卓/位置/地理位置coder.html 。你提的这个过程被称为反向地理编码。我认为这是相当准确的(特别是如果只需要一个城市的名字),我用它在我的一些项目。

You need the Geocoder class for that. See the reference, it's quite easy to use: http://developer.android.com/reference/android/location/Geocoder.html . The process you're mentioning is called reverse geocoding. I think it's quite accurate (especially if only the city name is needed), I've used it in some of my projects.

但是,如果您只想确定用户当前的城市,它可能是足够使用的小区信息,而不是那么GPS提供商。对于GPS工作,用户必须以外,基于小区信息的提供者工作得很好建筑物内太

But if you only want to determine the city the user's currently in, it might be enough to use the cell information for that, rather then the gps provider. For the gps to work, the user has to be outside, the provider based on cell info works quite well inside buildings too.

这篇关于有没有办法准确判断用户在使用Android位置管理器哪个城市在美国​​?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆