Local Search (iOS) Follow
This article describes how to show points of interest near the user’s location using the iOS SDK. The underlying Local Search API has some limitations you should understand before using it in your application.
Use Local Search
You can use the MRLocalSearch, MRLocalSearchRequest, MRPlacemarkResponse, MRPlacemarkResult classes to find points of interest near the user’s location. Combine these classes with MRLocationManager to provide a location and its nearby placemarks.
For best performance, limit local search results to 20 or less.
- (void)findNearbyCafe { MRLocalSearchRequest *request = [MRLocalSearchRequest new]; request.app = self.appKey; request.location = self.locationManager.location; request.transportType = MRDirectionsTransportTypeWalking; request.naturalLanguageQuery = @"Cafe"; request.limit = 20; MRLocalSearch *search = [[MRLocalSearch alloc] initWithRequest:request]; [self.search startWithCompletionHandler:^(MRPlacemarkResponse *response, NSError *error) { if (response) { for (MRPlacemarkResult *result in response.results) NSLog(@"%@ is %f seconds away", result.placemark.name, result.expectedTravelTime); } else if (error) { NSLog(@"Error loading search results: %@", error.localizedDescription); } }]; }
Comments
0 comments
Please sign in to leave a comment.