3

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

4

3 回答 3

5

要检查某个位置是否存在街景全景图,您必须使用GMSPanoramaService 类

-(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);
     }
}
于 2014-08-10T08:51:24.977 回答
1

解决此问题的一种方法是实现以下GMSPanoramaViewDelegate方法:

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

如果panorama.panoramaIDNSString 为空,则无法加载全景图。

于 2014-01-07T22:06:31.743 回答
1

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.

于 2018-02-12T18:26:25.103 回答