从地址获取位置坐标

Getting location coordinates from Address

系统会提示用户在文本字段中输入他的地址,在后台我想获取地址的位置坐标。

我正在使用 google 的地理编码服务,但没有使用他们的任何 API。我在他们的文档中的某处读到“将地理编码器用于获取将使用 google 地图 API 显示的位置以外的任何目的都违反了服务条款”。

这就是我使用 HTTP 请求的方式

http://maps.googleapis.com/maps/api/geocode/json?address=ADDRESS_STRING&sensor=false

我可以这样做吗?我很困惑,因为我根本没有显示任何地图,但我想获取坐标。这会违反他们的条款吗?

不幸的是,是的,我认为你会在这里违反 Google 的规则。另请参阅 this 答案。

您仍然可以使用 iOS' 内置的正向地理编码引擎。有关文档,请参阅 here

Google 地图条款非常严格。但是,看起来他们确实允许在没有 Google 地图 (Geocoding API Policies) 的情况下显示结果:

You can display Geocoding API results on a Google Map, or without a map. If you want to display Geocoding API results on a map, then these results must be displayed on a Google Map. It is prohibited to use Geocoding API data on a map that is not a Google map.

因此您无法在“非Google”地图上显示 Google 地理编码 API 结果。

尽管如此,请记住您仍然无法缓存(仅 lat/long 在最终使用设备上 30 天)和存储结果。

幸运的是,有许多基于开放数据的地理编码服务。例如,我们在 Geoapify 允许我们的客户存储甚至重新分发数据。试试我们的 Geocoding API,也许您会发现它是 Google.

地理编码服务的一个有价值的替代品