【问题标题】:How to check google street view is available or not for a perticular location coordinate如何检查特定位置坐标的谷歌街景是否可用
【发布时间】:2013-07-22 20:53:15
【问题描述】:

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

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

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

但是怎么用呢?

提前致谢!

【问题讨论】:

    标签: ios ipad google-maps google-street-view


    【解决方案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];
    
    
    
    }
    

    【讨论】:

    • 这段代码不完整,NWisStreetViewCompletionBlock 没有定义
    • typedef void (^NWisStreetViewCompletionBlock) (NSString *panoIdOfPlace, NSError *error);
    • 当然,我认为这很容易:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-17
    • 1970-01-01
    相关资源
    最近更新 更多