如何根据 Android phone 配置获取某个国家/地区的位置点
How can I get a location point on a country depend on Android phone configuration
我正在使用 Google 地图开发一个 android 应用程序。在应用启动时,如果用户没有打开定位服务(无法获取用户当前位置,对吧?),
我希望我的地图根据 phone 的配置缩放到当前用户所在的国家/地区。我该怎么做?
嗯,当然,您可以使用用户的系统语言来猜测他们的位置。但是您知道,美国的每个人可能都使用相同的语言。
如果您不能使用 GPS,下一个最好的办法是通过某种 IP 地址定位器来确定用户的位置。甚至 google 地图也提供了自己的 IP 来定位服务,但他们已经有一段时间没有更新了。另请查看 this post 了解更多信息。
您应该考虑使用像这样的某种 API
http://www.telize.com/
GeoIP (Get IP address location in JSON format) :
Calling the API endpoint without any parameter will return location information for the visitor IP address :
Example (JSON) : http://www.telize.com/geoip
{"longitude":-97,"latitude":38,"asn":"AS15169","ip":"xxxx:x:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx",
"area_code":"0","continent_code":"NA","dma_code":"0","country_code":"US",
"isp":"Google Inc.","country":"United States","country_code3":"USA"}
我正在使用 Google 地图开发一个 android 应用程序。在应用启动时,如果用户没有打开定位服务(无法获取用户当前位置,对吧?),
我希望我的地图根据 phone 的配置缩放到当前用户所在的国家/地区。我该怎么做?
嗯,当然,您可以使用用户的系统语言来猜测他们的位置。但是您知道,美国的每个人可能都使用相同的语言。
如果您不能使用 GPS,下一个最好的办法是通过某种 IP 地址定位器来确定用户的位置。甚至 google 地图也提供了自己的 IP 来定位服务,但他们已经有一段时间没有更新了。另请查看 this post 了解更多信息。
您应该考虑使用像这样的某种 API http://www.telize.com/
GeoIP (Get IP address location in JSON format) :
Calling the API endpoint without any parameter will return location information for the visitor IP address :
Example (JSON) : http://www.telize.com/geoip
{"longitude":-97,"latitude":38,"asn":"AS15169","ip":"xxxx:x:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx", "area_code":"0","continent_code":"NA","dma_code":"0","country_code":"US", "isp":"Google Inc.","country":"United States","country_code3":"USA"}