Google Place Picker致命错误?

时间:2016-02-17 17:17:59

标签: ios xcode swift

我在使用此代码时遇到致命错误。任何帮助将不胜感激。似乎动画回到谷歌地图导致它但不确定为什么....

@IBAction func showPlacePicker(sender: AnyObject) {

    // The code snippet below shows how to create a GMSPlacePicker
    // centered on self, and output details of a selected place.

        let center = CLLocationCoordinate2DMake(37.7778640, -122.4368020)
        let northEast = CLLocationCoordinate2DMake(center.latitude + 0.001, center.longitude + 0.001)
        let southWest = CLLocationCoordinate2DMake(center.latitude - 0.001, center.longitude - 0.001)
        let viewport = GMSCoordinateBounds(coordinate: northEast, coordinate: southWest)
        let config = GMSPlacePickerConfig(viewport: viewport)
        placePicker = GMSPlacePicker(config: config)

        placePicker?.pickPlaceWithCallback({ (place: GMSPlace?, error: NSError?) -> Void in
            if let error = error {
                print("Pick Place error: \(error.localizedDescription)")
                return

            }

                if let place = place {
                    let coordinates = CLLocationCoordinate2DMake(place.coordinate.latitude, place.coordinate.longitude)
                    let marker = GMSMarker(position: coordinates)
                    marker.title = place.name
                    marker.map = self.googleMapView
                    self.googleMapView.animateToLocation(coordinates)


            } else {
                print("No place was selected")

                          }




            })


}

0 个答案:

没有答案