在iOS地图中search附近

我正在尝试使用MapKit构build一个简单的应用程序,该应用程序将在应用程序启动时自动search特定位置,并在位置的地图上放置引脚。 我看到各种方式来加载位置(纬度/经度等),但没有什么可以让我search具体的商业名称,餐厅名称等。

我期待着与苹果地图合作。 但是,如果Google地图比这样做更好解决问题。

任何帮助,将不胜感激。 谢谢

iOS> = 6.1提供了MKLocalSearch , MKLocalSearchRequest来search感兴趣的自然语言点。 样品

MKLocalSearchRequest *request = [[MKLocalSearchRequest alloc] init]; request.region = regionToSearchIn; request.naturalLanguageQuery = @"restaurants"; // or business name MKLocalSearch *localSearch = [[MKLocalSearch alloc] initWithRequest:request]; [localSearch startWithCompletionHandler:^(MKLocalSearchResponse *response, NSError *error) { // do something with the results / error }]; 

我知道它晚了,但希望这有助于!

 [super viewDidLoad]; [self.searchDisplayController setDelegate:self]; [self.ibSearchBar setDelegate:self]; self.ibMapView.delegate=self; // Zoom the map to current location. [self.ibMapView setShowsUserLocation:YES]; [self.ibMapView setUserInteractionEnabled:YES]; [self.ibMapView setUserTrackingMode:MKUserTrackingModeFollow]; CLLocationManager *locationManager = [[CLLocationManager alloc] init]; locationManager.delegate=self; [locationManager startUpdatingLocation]; [self.ibMapView setRegion:MKCoordinateRegionMake(locationManager.location.coordinate, MKCoordinateSpanMake(0.2, 0.2))]; MKLocalSearchRequest *request = [[MKLocalSearchRequest alloc] init]; request.region = self.ibMapView.region; request.naturalLanguageQuery = @"restaurant"; [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; localSearch = [[MKLocalSearch alloc] initWithRequest:request]; [localSearch startWithCompletionHandler:^(MKLocalSearchResponse *response, NSError *error){ [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; results = response; if (response.mapItems.count == 0) NSLog(@"No Matches"); else for (MKMapItem *item in response.mapItems) { NSLog(@"name = %@", item.name); NSLog(@"Phone = %@", item.phoneNumber); [_matchingItems addObject:item]; MKPointAnnotation *annotation = [[MKPointAnnotation alloc]init]; annotation.coordinate = item.placemark.coordinate; annotation.title = item.name; [self.ibMapView addAnnotation:annotation]; } }]; 

}

按以下步骤显示最近的地方。

使用谷歌APIfind最近的地方Google Places API

谷歌API提供LAt和长和地址信息。

然后将LAt和Long值存储到数组,然后使用这个经纬度值,您可以在苹果地图(iOS 6+)和Google地图(iOS 5)中显示注释。