Lance Samaria Lance Samaria - 1 month ago 7
Swift Question

GoogleAPI PanoView StreetView Bug -image not loading correctly

I'm using google street view in a an iOS app I'm developing. I have a panoView set up inside the vc and it seems that when I type in certain US addresses I get a pano image for some but not for others. For the locations that I don't get an image for I instead get a grey loading screen. I go to regular google and type in that same exact address and google shows an image does exist. Why is it not working for some addresses but it does for others?

Here's an address that I do get an image for:

253 w. 125 St, New York NY 10027 -coordinates(lat: 40.809847, lon:-73.950378)

But I get a grey loading screen for address:

150 W 225 St, Bronx NY 10463 -coordinates(lat: 40.8754871, lon: -73.9137233)

I get a debugger error message of:

1.Moving near coordinate (40.8754871,-73.9137233 error: The operation couldn’t be completed. ( error 0.)?.

I have already set my Scheme to Schemes>Edit Scheme>Options>AllowLocationSimulation>DefaultLocation>New York, NY, USA

What's the problem?

Btw I'm using Xcode 7.3.1

import UIKit
import GoogleMaps

class SearchController: UIViewController, GMSMapViewDelegate, GMSPanoramaViewDelegate {

@IBOutlet weak var viewStreet: UIView!
var panoView: GMSPanoramaView!

var buildingLat: CLLocationDegrees?
var buildingLon: CLLocationDegrees?
var panoramaID: String?
let placesClient = GMSPlacesClient()

func viewDidLoad() {

panoView = GMSPanoramaView(frame: CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height))
panoView.delegate = self
panoView.moveNearCoordinate(CLLocationCoordinate2D(latitude: buildingLat!, longitude: buildingLon!))
print("\nlat: \(buildingLat)\nlon: \(buildingLon)\n")

// MARK: - GMSPanoramaViewDelegate
func panoramaView(view: GMSPanoramaView, error: NSError, onMoveNearCoordinate coordinate: CLLocationCoordinate2D) {
print("\n1.Moving near coordinate (\(coordinate.latitude),\(coordinate.longitude) error: \(error.localizedDescription)?\n")

func panoramaView(view: GMSPanoramaView, error: NSError, onMoveToPanoramaID panoramaID: String) {
print("\n2.Moving to PanoID \(panoramaID) error: \(error.localizedDescription)??\n")

func panoramaView(view: GMSPanoramaView, didMoveToPanorama panorama: GMSPanorama?) {
print("\n3.Moved to panoramaID: \(panorama!.panoramaID) " +
"coordinates: (\(panorama!.coordinate.latitude),\(panorama!.coordinate.longitude))???\n")

self.panoramaID = panorama!.panoramaID



I fixed it myself. I simply added in a radius on the method:

moveNearCoordinate(coordinate: CLLocationCoordinate2D, radius: Uint)

//Inside my viewDidLoad on the 4th line
panoView.moveNearCoordinate(CLLocationCoordinate2D(latitude: buildingLat!, longitude: buildingLon!), radius: 100)

You can play with the radius to see what suits you best