我正在实施iOS地图视图。我设置了Google Search Api来实施地方搜索。
我使用了像这样的cocoapods
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
- 此地点的推荐视口。
但是,如果我在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 }
}
我需要做什么才能获得所需的课程?
祝福。
答案 0 :(得分:0)
最新的cocoapod有它!我只需要更新。