【发布时间】:2014-08-16 15:42:50
【问题描述】:
我在keizersgrachtAmsterdam 拍了一张照片。我正在构建一个功能,如果照片的位置和 Foursquare 场地之间存在严格匹配,我会包含一个拍摄照片的位置。否则,我希望结果是nil。
我正在进行的 Foursquare API 调用的文档可以在这里找到:https://developer.foursquare.com/docs/venues/search
由于我不知道这张照片是在什么样的场地拍摄的,所以我无法添加query 参数,它从选项中排除了intent=match。作为一种解决方法,我选择使用 intent=checkin 并将几乎所有 categoryId's 添加到请求中。
我的请求现在看起来像这样:
//latitude & longitude are taken as parameters to the method
NSString *clientId = @"redacted";
NSString *clientSecret = @"redacted";
NSString *version =@"20140806";
NSString *limit = @"1";
NSString *radius = @"1";
NSString *categoryId = @"4d4b7104d754a06370d81259,4bf58dd8d48988d1b4941735,4bf58dd8d48988d1b2941735,4bf58dd8d48988d1a8941735,4bf58dd8d48988d1ad941735,4d4b7105d754a06373d81259,4d4b7105d754a06374d81259,4d4b7105d754a06376d81259,4d4b7105d754a06377d81259,4d4b7105d754a06375d81259,4e67e38e036454776db1fb3a,4d4b7105d754a06378d81259,4d4b7105d754a06379d81259"; //almost all the cat id's
NSDictionary *venueResponse = [self getDataFrom:[NSString stringWithFormat:@"https://api.foursquare.com/v2/venues/search?client_id=%@&client_secret=%@&v=%@&ll=%@,%@&m=foursquare&limit=%@&radius=%@&intent=checkin&categoryId=%@", clientId, clientSecret, version, lat, lng, limit, radius, categoryId]];
NSLog(@"%@",venueResponse);
getDataFrom 方法是关于发出一个简单的 GET 请求。
但是,当我经过阿姆斯特丹市中心的某个位置时,我得到了超出半径范围的结果,如下所示:(sn-p)
cc = NL;
city = Amsterdam;
country = Netherlands;
distance = 24;
formattedAddress = (
Amsterdam,
Netherlands
);
这很奇怪,因为我特地添加了半径 1。
这是什么原因造成的,我该怎么办?
【问题讨论】:
-
您知道距离和半径值以米为单位吗?
-
我是。所以这实际上意味着它们是相同的值..
标签: ios objective-c geolocation foursquare