如何从 Google 地点 API 在 ios Swift 中获取坐标
How to get Coordinates from Google Places API in ios Swift
我正在使用 Alamofire
和 SwiftyJSON
来自动完成 Google 个地点。我把它整合得很好,就像这样:
现在,我需要的是,如果我 select 来自 table 视图的一个地方,它是 select 在文本字段中编辑的。但是我怎样才能得到那个地方各自的经纬度,这样我就可以在MapKit中添加那个地方的注释
从 Google Place API
获取详细信息并将其显示在苹果的 MapKit 上是否合法?看到 Viking 的 question
后,我有这个疑问
您可以从 GMSPlace
对象中获取坐标。参见 documentation.
关于是否可以在 apple 地图旁边使用 google 个地点,不可以。
正如他们在 Terms of Use
中所述
Make sure that any maps used by your app to show the location of places retrieved from the Google Places API for iOS are Google maps.
也许我没有迟到,但仍然作为教程,我发布了这个答案
你可以简单地得到这样的坐标
// Handle the user's selection
public func viewController(viewController: GMSAutocompleteViewController, didAutocompleteWithPlace place: GMSPlace) {
var lat = place.coordinate.latitude
var lon = place.coordinate.longitude
print("lat lon",lat,lon)
}
我正在使用 Alamofire
和 SwiftyJSON
来自动完成 Google 个地点。我把它整合得很好,就像这样:
现在,我需要的是,如果我 select 来自 table 视图的一个地方,它是 select 在文本字段中编辑的。但是我怎样才能得到那个地方各自的经纬度,这样我就可以在MapKit中添加那个地方的注释
从 Google Place API
获取详细信息并将其显示在苹果的 MapKit 上是否合法?看到 Viking 的 question
您可以从 GMSPlace
对象中获取坐标。参见 documentation.
关于是否可以在 apple 地图旁边使用 google 个地点,不可以。 正如他们在 Terms of Use
中所述Make sure that any maps used by your app to show the location of places retrieved from the Google Places API for iOS are Google maps.
也许我没有迟到,但仍然作为教程,我发布了这个答案 你可以简单地得到这样的坐标
// Handle the user's selection
public func viewController(viewController: GMSAutocompleteViewController, didAutocompleteWithPlace place: GMSPlace) {
var lat = place.coordinate.latitude
var lon = place.coordinate.longitude
print("lat lon",lat,lon)
}