Ios 如何在我的应用程序中获得与apple maps相同的搜索提示
我在iOS应用程序中实现了搜索栏。我希望得到与Apple Maps应用程序相同的(部分结果)搜索提示。 我试图找出苹果是如何实现它的,但在谷歌和stackoverflow上我都没有成功 我的UITableView*searchHintTableView中到底显示了什么并不重要。我只是没有得到正确数量的搜索提示。 我在同一台设备和同一个3G wifi网络(3G SIM路由器)上使用我的应用程序和Apple Maps应用程序 我尝试过的一切:Ios 如何在我的应用程序中获得与apple maps相同的搜索提示,ios,objective-c,geocoding,apple-maps,Ios,Objective C,Geocoding,Apple Maps,我在iOS应用程序中实现了搜索栏。我希望得到与Apple Maps应用程序相同的(部分结果)搜索提示。 我试图找出苹果是如何实现它的,但在谷歌和stackoverflow上我都没有成功 我的UITableView*searchHintTableView中到底显示了什么并不重要。我只是没有得到正确数量的搜索提示。 我在同一台设备和同一个3G wifi网络(3G SIM路由器)上使用我的应用程序和Apple Maps应用程序 我尝试过的一切: 我试图用半径指定区域 从以前的请求中取消地理编码 在
- 我试图用半径指定区域
- 从以前的请求中取消地理编码
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText;
我有以下代码:
...
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
NSString *location = [NSString stringWithFormat:@"%@", searchText];
// CLRegion *region = [[CLRegion alloc] initCircularRegionWithCenter:coord
// radius:100000000 identifier:@"Hint Region"];
// [geocoder cancelGeocode];
[geocoder geocodeAddressString:location
completionHandler:^(NSArray *placemarks, NSError *error) {
if (error != nil) {
DDLogCVerbose(@"Error %@", [error description]);
[searchHintArray removeAllObjects];
[searchHintTableView reloadData];
return;
}
DDLogCVerbose(@"CLGeocoder >> %@", [placemarks description]);
//to get rid of unwanted results when searchText is inadequate
//even when previous partial results are not removed I don't get that many results as Apple Maps application.
[searchHintArray removeAllObjects];
[placemarks enumerateObjectsUsingBlock:^(CLPlacemark *placemark, NSUInteger idx, BOOL *stop) {
MKPlacemark *mkPlacemark = [[MKPlacemark alloc] initWithPlacemark:placemark];
[searchHintArray addObject:mkPlacemark];
}];
[searchHintTableView reloadData];
}
];
...
输入参数如下
- 搜索文本:Ess
- 纬度:51.46
- 经度:7.01
我的问题是如何实现与苹果地图iOS应用程序相同的结果。当我输入地址的大部分或完整地址时,我会得到准确的位置。当我输入地址的一小部分时,我只是没有得到相同数量的结果 看看这个答案:据我所知,你无法用Apple MapKit API实现你想要的结果。下面是正确的答案:用不同的线程在4年内回答。应该有徽章“古代怪物屠杀”;)