MQSearchAheadService

@interface MQSearchAheadService : NSObject

The main MapQuest Search Ahead service object

  • The search call without a geographic context

    Declaration

    Objective-C

    - (void)predictResultsForQuery:(nonnull NSString *)query
                       collections:(nonnull NSArray *)collections
                           options:(nullable MQSearchAheadOptions *)options
                           success:(nullable void (^)(
                                       MQSearchAheadResponse *_Nonnull))success
                           failure:(nullable void (^)(NSError *_Nonnull))failure;

    Swift

    func predictResults(forQuery query: String, collections: [Any], options: MQSearchAheadOptions?, success: ((MQSearchAheadResponse) -> Void)?, failure: ((Error) -> Void)? = nil)

    Parameters

    query

    A query phrase. The phrase can be incomplete, in which case its last term is treated as a prefix during matching. Address queries must begin with a street number. Minimum 2 characters, maximum 100 characters

    collections

    The following collections are currently supported: MQSearchAheadCollectionAddress, MQSearchAheadCollectionAdminArea, MQSearchAheadCollectionAirport, MQSearchAheadCollectionPOI, MQSearchAheadCollectionCategory, and MQSearchAheadCollectionFranchise

    options

    An instance of MQSearchAheadOptions where you can set the language, result limit, and whether the results include feedback

    success

    A block that handles the search results

    failure

    A block that handles the failure of a search call

  • The search call with a geographic context

    Declaration

    Objective-C

    - (void)predictResultsForQuery:(nonnull NSString *)query
                       collections:(nonnull NSArray *)collections
                          location:(CLLocationCoordinate2D)location
                           options:(nullable MQSearchAheadOptions *)options
                           success:(nullable void (^)(
                                       MQSearchAheadResponse *_Nonnull))success
                           failure:(nullable void (^)(NSError *_Nonnull))failure;

    Swift

    func predictResults(forQuery query: String, collections: [Any], location: CLLocationCoordinate2D, options: MQSearchAheadOptions?, success: ((MQSearchAheadResponse) -> Void)?, failure: ((Error) -> Void)? = nil)

    Parameters

    query

    A query phrase. The phrase can be incomplete, in which case its last term is treated as a prefix during matching. Address queries must begin with a street number. Minimum 2 characters, maximum 100 characters

    collections

    The following collections are currently supported: MQSearchAheadCollectionAddress, MQSearchAheadCollectionAdminArea, MQSearchAheadCollectionAirport, MQSearchAheadCollectionPOI, MQSearchAheadCollectionCategory, and MQSearchAheadCollectionFranchise

    location

    The geographic context used for searching, ranking, and ordering results. Supports a point defining the geographic center of the query. While this parameter is not required, it is highly recommended that it be provided in order to improve relevance of results.

    options

    An instance of MQSearchAheadOptions where you can set the language, result limit, and whether the results include feedback

    success

    A block that handles the search results

    failure

    A block that handles the failure of a search call

  • Returns true or false if the search service is waiting on a response from the server

    Declaration

    Objective-C

    - (BOOL)inFlight;

    Swift

    func inFlight() -> Bool

    Return Value

    return true or false