MKLocalSearch没有找到明显的结果 [英] MKLocalSearch not finding obvious results
问题描述
我的代码几乎与以下示例完全相同:
详细信息(lat,lon需要此信息):
https://开发人员.google.com / places / documentation / details
在 JSONModel 我在几个小时内将它构建到我的iOS应用程序中。
结果正是我希望看到的:
My code is virtually identical to the following example:
https://github.com/iamamused/Example-MKLocalSearch.git
Here are the important bits:
@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet MKMapView *ibMapView;
@end
@implementation ViewController {
MKLocalSearch *localSearch;
MKLocalSearchResponse *results;
}
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
[localSearch cancel];
MKLocalSearchRequest *request = [[MKLocalSearchRequest alloc] init];
request.naturalLanguageQuery = searchBar.text;
request.region = self.ibMapView.region;
localSearch = [[MKLocalSearch alloc] initWithRequest:request];
[localSearch startWithCompletionHandler:^(MKLocalSearchResponse *response, NSError *error){
[self.resultTable reloadData];
}
}
It seems reasonable that when Sutter and Mason aka 600 Sutter St. are inside the map region searching for "600 Sutte" would include the obvious result "600 Sutter St.". I just can't get that to work. I've tried many different streets and I often get results out of state before I get results that are directly in the map region.
Also, "600 Sut" returns irrelevant results, while "600 Su" returns an error 4. Did it really not find anything that starts with "600 Su"?
Am I using this API completely wrong or is it not meant for what I'm trying to do with it?
Map Region for all queries:
600 Sutte
600 Su
I ended up giving up on Apple local search API and switching to Google. Their Place API is exactly what I needed. It finds relevant results quickly and up to 100k requests per day doesn't cost anything.
Auto-complete: https://developers.google.com/places/documentation/autocomplete
Details (need this for lat, lon): https://developers.google.com/places/documentation/details
With the help of JSONModel I built it into my iOS app in a few hours.
The results are exactly what I was hoping to see:
这篇关于MKLocalSearch没有找到明显的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!