我正在实现一个iOS地图视图。我设置了Google Search Api以实施地点搜索。
我用了像这样的椰壳
pod 'Google' , '~> 1.2.1'
pod 'GoogleMaps', '~> 1.11.0'
当用户搜索一些关键字时,我会得到
GMSPlace
的列表。当用户选择GMSPlace
对象中的一个时,我运行此代码来获取坐标。placesClient?.lookUpPlaceID(placeID, callback: { (place: GMSPlace?, error: NSError?) -> Void in
if let place = place {
print("Place name \(place.name)")
print("Place coordinate \(place.coordinate)")
// how to find the viewport?
} else {
print("No place details for \(placeID)")
}
})
如果您在这里看看,https://developers.google.com/maps/documentation/ios-sdk/reference/interface_g_m_s_place
GMSPlace
具有成员viewport
-此位置的推荐视口。但是,如果我按CMD单击Xcode中的GMSPlace,我就会进入此类。它没有视口成员。
/**
* Represents a particular physical place. A GMSPlace encapsulates information about a physical
* location, including its name, location, and any other information we might have about it. This
* class is immutable.
*/
public class GMSPlace : NSObject {
/** Name of the place. */
public var name: String! { get }
/** Place ID of this place. */
public var placeID: String! { get }
/**
* Location of the place. The location is not necessarily the center of the Place, or any
* particular entry or exit point, but some arbitrarily chosen point within the geographic extent of
* the Place.
*/
public var coordinate: CLLocationCoordinate2D { get }
/**
* Represents the open now status of the place at the time that the place was created.
*/
public var openNowStatus: GMSPlacesOpenNowStatus { get }
/**
* Phone number of this place, in international format, i.e. including the country code prefixed
* with "+". For example, Google Sydney's phone number is "+61 2 9374 4000".
*/
public var phoneNumber: String! { get }
/**
* Address of the place as a simple string.
*/
public var formattedAddress: String! { get }
/**
* Five-star rating for this place based on user reviews.
*
* Ratings range from 1.0 to 5.0. 0.0 means we have no rating for this place (e.g. because not
* enough users have reviewed this place).
*/
public var rating: Float { get }
/**
* Price level for this place, as integers from 0 to 4.
*
* e.g. A value of 4 means this place is "$$$$" (expensive). A value of 0 means free (such as a
* museum with free admission).
*/
public var priceLevel: GMSPlacesPriceLevel { get }
/**
* The types of this place. Types are NSStrings, valid values are any types documented at
* <https://developers.google.com/places/supported_types>.
*/
public var types: [AnyObject]! { get }
/** Website for this place. */
@NSCopying public var website: NSURL! { get }
/**
* The data provider attribution string for this place.
*
* These are provided as a NSAttributedString, which may contain hyperlinks to the website of each
* provider.
*
* In general, these must be shown to the user if data from this GMSPlace is shown, as described in
* the Places API Terms of Service.
*/
@NSCopying public var attributions: NSAttributedString! { get }
}
我需要做什么才能获得期望的 class ?
最好的祝愿。
最佳答案
最新的cocoapod有它!我只需要更新。