GLSearch
Objective-C
@interface GLSearch : NSObject
Swift
class GLSearch : NSObject
GLSearch
class contains a set of parameters that defines search in offline maps
-
Initilaize GLSearch from json string
Declaration
Objective-C
- (instancetype _Nullable)initFromJSON:(nonnull NSString *)json;
Swift
init?(fromJSON json: String)
Parameters
json
json string with paramters.
-
Adds 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
tiles
Set of tile hashes
-
Sets locale settings that used to sort results by importance. Results in user language displayed on top.
Declaration
Objective-C
- (void)setLocaleSettings:(nonnull GLMapLocaleSettings *)localeSettings;
Swift
func setLocaleSettings(_ localeSettings: GLMapLocaleSettings)
Parameters
localeSettings
Language priority settings.
-
Adds filter to search. Result of search will contain objects that matches all filters
Declaration
Objective-C
- (void)addFilter:(nonnull GLSearchFilter *)filter;
Swift
func add(_ filter: GLSearchFilter)
Parameters
filter
filter to add.
-
Sets maximum number of results to fetch from map
Declaration
Objective-C
@property (nonatomic) NSUInteger limit;
Swift
var limit: UInt { get set }
-
Sets center of search. Distance from this center will define importance of object. Usually center is user location or center of the screen.
Declaration
Objective-C
@property (nonatomic) GLMapPoint center;
Swift
var center: GLMapPoint { get set }
-
Set this value to
YES
if you plan to get address of objects. Loading address after search is much faster (cache reuse, bulk loading)Declaration
Objective-C
@property (nonatomic) BOOL needEnclosingAreas;
Swift
var needEnclosingAreas: Bool { get set }
-
Types of object
Declaration
Objective-C
@property (nonatomic) GLMapVectorObjectType objectTypes;
Swift
var objectTypes: GLMapVectorObjectType { get set }
-
Performs search synchronysly
Declaration
Objective-C
- (nonnull GLMapVectorObjectArray *)search;
Swift
func search() -> GLMapVectorObjectArray
-
Starts search.
Declaration
Objective-C
- (void)searchAsyncWithCompletionBlock: (nonnull GLSearchCompletionBlock)completionBlock;
Swift
func searchAsync() async -> GLMapVectorObjectArray
Parameters
completionBlock
Block will be called when search is finished.
-
Merges search results with custom objects
Declaration
Objective-C
- (nonnull NSArray *)mergeSearchResults: (nonnull GLMapVectorObjectArray *)searchResults withCustomObjects:(nonnull NSArray *)customObjects using:(nonnull GLSearchInfoBlock)infoBlock;
Swift
func mergeResults(_ searchResults: GLMapVectorObjectArray, withCustomObjects customObjects: [Any], using infoBlock: @escaping GLSearchInfoBlock) -> [Any]
Parameters
searchResults
Search results array
customObjects
Array of custom objects
infoBlock
Block that returns location, category and extra score for custom object
Return Value
Returns sorted array
-
Cancels search operation.
Declaration
Objective-C
- (void)cancel;
Swift
func cancel()
-
Serialize all settings as json string.
Declaration
Objective-C
- (nonnull NSString *)toJSON;
Swift
func toJSON() -> String
Return Value
Returns json string with search settings.
-
Splits string into words with rules that was 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
string
String with long text
Return Value
Returns array of words
-
Finds nearest vector object to some location on 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
point
Point
distance
Maximum distance from point
filters
Search filters applied to results
Return Value
Returns vector object or nil if nothing found in distance radius
-
Finds relation with near point with given osmID
Declaration
Objective-C
+ (GLMapRelation *_Nullable)findRelationNearPoint:(GLMapPoint)point osmID:(int64_t)osmID;
Swift
class func findRelationNearPoint(_ point: GLMapPoint, osmID: Int64) -> GLMapRelation?
Parameters
point
Point
osmID
osm ID