GLSearchRequest
Objective-C
@interface GLSearchRequest : NSObject
Swift
class GLSearchRequest : NSObject
Request model for GLSearch. The same request runs against either transport:
-startOnlineWithCompletion: queries the online search service (/v1/search,
/v1/autocomplete); -startOfflineWithCompletion: queries the downloaded offline maps.
Both apply the same ranking and display rules. The low-level GLSearch class
(tag filters over offline data) is separate.
The request returns GLMapVectorObject instances with display data baked on each object:
the primary name through the object’s localized name, the second line as the
search:secondaryText tag, and category/icon through GLMapVectorObject.searchCategory.
-
Request type: search or autocomplete.
Declaration
Objective-C
@property (nonatomic) GLSearchRequestType type;Swift
var type: GLSearchRequestType { get set } -
User query text.
Declaration
Objective-C
@property (nonatomic, copy) NSString *_Nonnull text;Swift
var text: String { get set } -
Ordered locale codes, for example
@[ @"be", @"ru", @"en" ]. The first entry is the preferred display language; every entry is used for matching.@"native"requests the map object’s native name. Pass nil or an empty array to use native names only.Declaration
Objective-C
@property (nonatomic, copy, nullable) NSArray<NSString *> *locales;Swift
var locales: [String]? { get set } -
Maximum number of results. Values less than 1 use defaults.
Declaration
Objective-C
@property (nonatomic) NSInteger limit;Swift
var limit: Int { get set } -
Search center used for result ranking. The center is not a strict geographic filter. The default non-finite value means a global request; assign a non-finite point to clear the center.
Declaration
Objective-C
@property (nonatomic) GLMapGeoPoint center;Swift
var center: GLMapGeoPoint { get set } -
GLSearch category identifiers, for example
@"cafe"or@"restaurant". An empty array means no category filter.Declaration
Objective-C
@property (nonatomic, copy) NSArray<NSString *> *_Nonnull categories;Swift
var categories: [String] { get set } -
Creates a search request from a type and text; locales, limit, center, and categories keep their defaults (no ranking center — global — and no category filter). Set the properties to customize.
Declaration
Objective-C
- (nonnull instancetype)initWithType:(GLSearchRequestType)type text:(nonnull NSString *)text;Swift
init(type: GLSearchRequestType, text: String)Parameters
typeRequest type: search or autocomplete.
textUser query text or autocomplete input.
Return Value
A new search request.
-
Creates a search request with a ranking center. The two nullable refinements (locales, categories) come last.
Declaration
Objective-C
- (nonnull instancetype)initWithType:(GLSearchRequestType)type text:(nonnull NSString *)text center:(GLMapGeoPoint)center limit:(NSInteger)limit locales:(NSArray<NSString *> *_Nullable)locales categories:(NSArray<NSString *> *_Nullable)categories;Swift
init(type: GLSearchRequestType, text: String, center: GLMapGeoPoint, limit: Int, locales: [String]?, categories: [String]?)Parameters
typeRequest type: search or autocomplete.
textUser query text or autocomplete input.
centerSearch center used for ranking nearby matches higher.
limitMaximum number of results. Pass 0 to use server defaults.
localesOrdered locale codes. The first entry is the display language; every entry is used for matching. Pass nil for native names.
categoriesGLSearch category identifiers. Pass nil for an unrestricted request.
Return Value
A new search request.
-
Starts the request against the online search service.
The completion block is called on the main queue, exactly once per start. A request with nothing to search (both text and categories are empty, or an autocomplete prefix is below the minimum length) completes with an empty result. Category-only requests are valid. A cancelled request completes with an
ECANCELEDerror.Declaration
Objective-C
- (int64_t)startOnlineWithCompletion: (nonnull GLSearchResultsCompletionBlock)completion;Swift
func startOnline(completion: @escaping GLSearchResultsCompletionBlock) -> Int64Parameters
completionBlock that receives parsed vector objects or an error.
Return Value
Request ID that can be passed to
+[GLSearchRequest cancel:], or 0 if the request completed without starting. -
Starts the same request against downloaded offline maps.
Text, categories, center, limit and locales are mapped to the offline search engine with the same rules the online server uses, so both paths can share one code path in the app.
The completion block is called on the main queue, exactly once per start. A request with nothing to search (both text and categories are empty, or an autocomplete prefix is below the minimum length) completes with an empty result. Category-only requests are valid. A cancelled request completes with an
ECANCELEDerror.Declaration
Objective-C
- (int64_t)startOfflineWithCompletion: (nonnull GLSearchResultsCompletionBlock)completion;Swift
func startOffline(completion: @escaping GLSearchResultsCompletionBlock) -> Int64Parameters
completionBlock that receives result vector objects or an error.
Return Value
Request ID that can be passed to
+[GLSearchRequest cancel:], or 0 if the request completed without starting. -
Cancels a request started with
-startOnlineWithCompletion:or-startOfflineWithCompletion:. The completion block of the cancelled request receives anECANCELEDerror.Declaration
Objective-C
+ (void)cancel:(int64_t)requestID;Swift
class func cancel(_ requestID: Int64)Parameters
requestIDRequest ID returned by the start method.
Install in Dash