GLSearch
Objective-C
@interface GLSearch : NSObject
Swift
class GLSearch : NSObject
GLSearch class performs search in offline maps.
-
Initialize GLSearch from a JSON string.
Declaration
Objective-C
- (instancetype _Nullable)initFromJSON:(nonnull NSString *)json;Swift
init?(fromJSON json: String)Parameters
jsonJSON string with parameters.
-
Adds a set of tile hashes to use for search (child tiles will be skipped).
Declaration
Objective-C
- (void)setTiles:(nonnull NSSet<NSNumber *> *)tiles;Swift
func setTiles(_ tiles: Set<NSNumber>)Parameters
tilesSet of tile hashes.
-
Sets locale settings that are used to sort results by importance. Results in the user’s language are displayed on top.
Declaration
Objective-C
- (void)setLocaleSettings:(nonnull GLMapLocaleSettings *)localeSettings;Swift
func setLocaleSettings(_ localeSettings: GLMapLocaleSettings)Parameters
localeSettingsLanguage priority settings.
-
Adds a filter to the search. The result of the search will contain objects that match all filters.
Declaration
Objective-C
- (void)addFilter:(nonnull GLSearchFilter *)filter;Swift
func add(_ filter: GLSearchFilter)Parameters
filterFilter to add.
-
Sets the maximum number of results to fetch from the map.
Declaration
Objective-C
@property (nonatomic) uint32_t limit;Swift
var limit: UInt32 { get set } -
Sets the center of the search (internal map coordinates). The distance from this center affects result ranking. Usually this is the user’s location or the map view center.
Declaration
Objective-C
@property (nonatomic) GLMapPoint center;Swift
var center: GLMapPoint { get set } -
Set this value to
YESif you plan to request address information for the results. Loading enclosing areas during search makes subsequent address loading faster (cache reuse, bulk loading).Declaration
Objective-C
@property (nonatomic) BOOL needEnclosingAreas;Swift
var needEnclosingAreas: Bool { get set } -
Types of objects
Declaration
Objective-C
@property (nonatomic) GLMapVectorObjectType objectTypes;Swift
var objectTypes: GLMapVectorObjectType { get set } -
Performs the search synchronously.
Warning
This can be expensive; run it off the main thread.Declaration
Objective-C
- (nonnull GLMapVectorObjectArray *)search;Swift
func search() -> GLMapVectorObjectArray -
Starts the search.
Declaration
Objective-C
- (void)searchAsyncWithCompletionBlock: (nonnull GLSearchCompletionBlock)completionBlock;Swift
func searchAsync() async -> GLMapVectorObjectArrayParameters
completionBlockBlock will be called when the search is finished.
-
Cancels the search operation.
Declaration
Objective-C
- (void)cancel;Swift
func cancel() -
Serialize all settings as a JSON string.
Declaration
Objective-C
- (nonnull NSString *)toJSON;Swift
func toJSON() -> StringReturn Value
Returns a JSON string with search settings.
-
Merges search results with custom objects.
Declaration
Objective-C
+ (nonnull NSArray *)mergeSearchResults: (nonnull GLMapVectorObjectArray *)searchResults withCustomObjects:(nonnull NSArray *)customObjects center:(GLMapPoint)center using:(nonnull GLSearchInfoBlock)infoBlock;Swift
class func mergeResults(_ searchResults: GLMapVectorObjectArray, withCustomObjects customObjects: [Any], center: GLMapPoint, using infoBlock: @escaping GLSearchInfoBlock) -> [Any]Parameters
searchResultsSearch results array.
customObjectsArray of custom objects.
centerCenter used to rank the merged results by proximity.
infoBlockBlock that returns location, category, and extra score for the custom object.
Return Value
A sorted array that contains
GLMapVectorObjectinstances and objects fromcustomObjects. -
Splits a string into words with rules that were used to generate search indexes. Uses ICU inside. Works even for Japanese glyphs without spaces.
Declaration
Objective-C
+ (nonnull NSArray<NSString *> *)splitByWords:(nonnull NSString *)string;Swift
class func split(byWords string: String) -> [String]Parameters
stringString with long text.
Return Value
Returns an array of words.
-
Finds the nearest vector object to a certain location on the map.
Declaration
Objective-C
+ (GLMapVectorObject *_Nullable) nearestToPoint:(GLMapPoint)point maxDistance:(double)distance withFilters:(NSArray<GLSearchFilter *> *_Nullable)filters;Swift
class func nearest(to point: GLMapPoint, maxDistance distance: Double, with filters: [GLSearchFilter]?) -> GLMapVectorObject?Parameters
pointPoint in internal map coordinates.
distanceMaximum distance from the point, in meters.
filtersSearch filters applied to results.
Return Value
Returns a vector object or nil if nothing was found in the distance radius.
-
Finds a relation with a near point with a given osmID.
Declaration
Objective-C
+ (GLMapRelation *_Nullable)findRelationNearPoint:(GLMapPoint)point osmID:(int64_t)osmID;Swift
class func findRelationNearPoint(_ point: GLMapPoint, osmID: Int64) -> GLMapRelation?Parameters
pointPoint in internal map coordinates.
osmIDOSM ID.
Install in Dash