0

我正在使用适用于 iOS 版本的 Google Maps SDK:1.4.0.4450 从我的 ios 应用程序显示特定位置的 google 街景。如果街景可用,它工作正常。

我的问题是如果街景不可用如何检查?

有一个 GMSPanoramaService 类。它包含一个公共成员方法。我认为这很有用。- requestPanoramaNearCoordinate:callback: 检索给定坐标附近的全景信息。

但是如何使用呢?

提前致谢!

4

1 回答 1

-1

你可以使用这种粗鲁的方法

-(void)isStreetViewAvailable:(CLLocationCoordinate2D)location completionBlock:    (NWisStreetViewCompletionBlock)completionBlock
 {
 NSString *loc = [NSString stringWithFormat:@"%.10f,%.10f&", location.latitude, location.longitude];
 NWisStreetViewCompletionBlock completeBlock = [completionBlock copy];


 NSString *connectionString = [NSString stringWithFormat:@"http://cbk0.google.com/cbk?output=json&ll=%@", loc];
 NSLog(@"connect to: %@",connectionString);

NSURL *url = [NSURL URLWithString:connectionString];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
AFJSONRequestOperation *operation;
operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
    //NSLog(@"%@", JSON);

    NSLog(@"%@", JSON);

    if([JSON objectForKey:@"Location"] == nil)
        completeBlock(@"", nil);

    //NSLog(@"panoId: %@",[[json objectForKey:@"Location"] objectForKey:@"panoId"]);

    completeBlock([[JSON objectForKey:@"Location"] objectForKey:@"panoId"], nil);



} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {

    NSMutableDictionary* details = [NSMutableDictionary dictionary];
    [details setValue:[error description] forKey:NSLocalizedDescriptionKey];
    // populate the error object with the details
    NSError *err = [NSError errorWithDomain:@"world" code:200 userInfo:details];

    completeBlock(NO, err);
}];

[operation start];



}
于 2013-07-22T12:53:15.213 回答