Search code examples
iosobjective-cgoogle-mapsgoogle-street-viewgmsmapview

GMSPanoramaView blank screen


I have a data set of coordinates in a KMZ file and I'd like to be able to give a user the option to view the street view with GMSPanoramaView (using the 1.6.0 version of Google-Maps-iOS-SDK). Here's what my code looks like:

GMSPanoramaView *panoView = [GMSPanoramaView panoramaWithFrame:CGRectZero nearCoordinate:self.placemark.point.coordinate];

This works great, except there are some coordinates which aren't available to GMSPanoramaView. For example, the following coordinate doesn't show up via the GMSPanoramaView:

latitude = 51.5308021862559, longitude = -0.16451295613534

GMSPanoramaView just shows a blank screen when it is initialised with these coordinates.

Is there any way to get an error back from GMSPanoramaView when it is presented with coordinates like this? I'd like to be able to display an error message to the user instead of just a blank screen :)

Sean


Solution

  • To check if a Streetview panorama exists for a certain location you have to use the GMSPanoramaService Class

    -(void) getStreetViewForCoordinate:(CLLocationCoordinate2D) coordinate {
        GMSPanoramaService *s = [[GMSPanoramaService alloc] init]; 
        [s requestPanoramaNearCoordinate: coordinate 
                                callback: ^(GMSPanorama *panorama, NSError *error) {
           NSLog(@"the service returned a panorama=%@ and an error=%@", panorama, error);
         }
    }