2012-09-12 48 views
5

在iOS 6中使用MapKit,我該如何在沒有特定座標的情況下獲取附近位置?我也不確定它是否仍有可能......錯誤... 允許 ...使用Google Maps API來實現此目標,因爲這是我能想到的唯一方法。

我知道一切仍處於測試階段,但在任何地方,關於此主題,論壇,Apple的新MapKit文檔中都找不到任何信息。我想要做的就是在用戶所在位置的'x'英里範圍內搜索位置(比如說,公園)。


看來,自從Apple開發了他們自己的Maps應用程序以來,他們應該有辦法使用MapKit或Core Location來完成這個任務......對吧?

iOS 6中的MapKit - 如何查找附近的地方...?

+4

對不起,但不能在SO上討論。它的NDA。試試Apple開發者論壇。蘋果工程師有時會在那裏閒逛。 –

+0

查看WWDC 2012視頻 - 這裏可能有些東西。他們做了類似的演示,但我不記得細節。道歉。 –

+0

它不再是NDA,6.1包含了實際的代碼,但仍然沒有任何文檔。我不知道蘋果公司發生了什麼事情,他們曾經是記錄事物的最佳人選,現在他們正在成爲另一種「解釋也很麻煩」的人。 – Rob

回答

2

試試用此代碼。這可能對你有幫助。

URLManager *urlmanager = [[URLManager alloc] init]; 
     urlmanager.delegate = self; 
     urlmanager.responseType = JSON_TYPE; 
     urlmanager.commandName = @"Search"; 

NSString *locationString = [NSString stringWithFormat:@"%f,%f",latitude,longitude]; 
//Location where you want to search 

NSString *key = @"AIzaSyCNRpero6aM451X0IfgFHAd-Y3eJUssqoa8`enter code here`0E"; 
//This is the secret key which you will get from the Google API Console when you register your app. 

NSString *radiuos = @"15000"; 
//This is the area within which you want to search 
NSString *keyword = @"Hotel";//Search keyword you want to search 

NSMutableDictionary *arguments = [[NSMutableDictionary alloc] init]; // zero argument 

[arguments setValue:key forKey:@"key"]; 

[arguments setValue:locationString forKey:@"location"]; 

[arguments setValue:radiuos forKey:@"radius"]; 

[arguments setValue:@"true" forKey:@"sensor"]; 

[arguments setValue:keyword forKey:@"keyword"]; 

NSLog(@"Arguments are %@",arguments); 

[urlmanager urlCallGetMethod:[NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/search/json"] withParameters:arguments];