GMSPlace viewport member missing in GoogleMaps cocoapod

若如初见. 提交于 2021-01-28 03:05:35

问题


I'm implementing an iOS Map View. I set up Google Search Api to implement a places search.

I used cocoapods like this

pod 'Google' , '~> 1.2.1'
pod 'GoogleMaps', '~> 1.11.0'

When the user searches for some keywords I get a list of GMSPlace. When the user selects on of the GMSPlace objects, I run this code to get the coordinates.

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)")
                    }
                })

If you take a look here https://developers.google.com/maps/documentation/ios-sdk/reference/interface_g_m_s_place GMSPlace has member viewport - The recommended viewport for this place.

But if I CMD-Click the GMSPlace in Xcode I come to this class. It does not have the viewport member.

    /**
 * 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 }
}

What do I need to do to get the desired class?

Best wishes.


回答1:


The newest cocoapod has it! I just had to update.



来源:https://stackoverflow.com/questions/34790121/gmsplace-viewport-member-missing-in-googlemaps-cocoapod

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!