如何检查谷歌街景视图是否可用于特定的位置坐标

时间:2013-07-22 12:29:43

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

我正在使用谷歌地图SDK for iOS版本从我的ios应用程序中显示谷歌街景以获取特定位置:1.4.0.4450。 如果街景可用,它可以正常工作。

我的问题是街道视图是否无法检查?

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

但如何使用呢?

提前致谢!

1 个答案:

答案 0 :(得分:-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];



}