Swift 2 GMSPanoramaCallback to determine if Google Street View is available

I am trying to use the method

panoViewService.requestPanoramaNearCoordinate(coordinate: CLLocationCoordinate2D: CLLocationCoordinate2D, callback: GMSPanoramaCallback)

  • How to convert a JSON string to a dictionary?
  • Programmatically get path to Application Support folder
  • Difference between using ObjectIdentifier() and '===' Operator
  • How do you instantiate a Storyboard from a file within an iOS playground?
  • multiple collectionView in multiple tableView cells
  • How to properly handle token refresh with Spotify SDK and Swift 3. Error Code=3840
  • where panoViewService = GMSPanoramaService()

    to check if a Google Street View is present for a particular coordinate. I am unclear on what is returned by the callback and how I can use it to load the street view if it is present or to load an alternative view if not. I know there are similar questions already posted, but none are for Swift 2 and I don’t know how to adapt the Obj-C code for Swift.

    Solutions Collect From Internet About “Swift 2 GMSPanoramaCallback to determine if Google Street View is available”

    Ok, I figured it out. The following code does what I need.

    var panoViewService = GMSPanoramaService()
    
    override func viewDidLoad() {
         super.viewDidLoad()
         let coord = place.position // data loaded from previous ViewController
    
         panoViewService.requestPanoramaNearCoordinate(coord, radius: 100) {
              GMSPanorama: GMSPanorama?, NSError: NSError?) in
    
             if GMSPanorama != nil {  // could have also used if NSError == nil
                  // code to load my panorama view here
             } else {
                 // do something else here
             }
         }
    

    }