Question

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

Was it helpful?

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

OTHER TIPS

One way to solve this is to implement the following GMSPanoramaViewDelegate method:

- (void)panoramaView:(GMSPanoramaView *)view didMoveToPanorama:(GMSPanorama *)panorama

If the panorama.panoramaID NSString is null, then the panorama could not be loaded.

In swift 4, Solved it by adding GMSPanoramaViewDelegate and implementing the following method

func panoramaView(_ view: GMSPanoramaView, error: Error, onMoveNearCoordinate coordinate: CLLocationCoordinate2D)

Only when panoramaView was not available, this method was hit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top