GLMapManager
Objective-C
@interface GLMapManager : NSObject
Swift
class GLMapManager : NSObject
Map manager used to work with list of offline maps
-
Activates GLMap framework. Should be called before usage.
@property key API key @property bundle Bundle with framework resources world.vm, fonts and DefaultStyle.bundle. If
null
uses main bundle. @property storagePath A path to folder where offline maps is stored. Ifnull
uses documents folder.Declaration
Objective-C
+ (void)activateWithApiKey:(nonnull NSString *)apiKey resourcesBundle:(NSBundle *_Nullable)resourcesBundle andStoragePath:(NSString *_Nullable)storagePath;
Swift
class func activate(withApiKey apiKey: String, resourcesBundle: Bundle?, andStoragePath storagePath: String?)
-
Unavailable
It’s singleton object. Use
[GLMapManager sharedManager]
Plain -init is disabled
Declaration
Objective-C
- (nonnull instancetype)init;
-
A path to folder where offline maps is stored
Declaration
Objective-C
@property (strong) NSString *_Nonnull storagePath;
Swift
var storagePath: String { get set }
-
Path to network activity log file. By default it’s nil and logging is disabled.
Declaration
Objective-C
@property (strong) NSString *_Nullable networkActivityLogPath;
Swift
var networkActivityLogPath: String? { get set }
-
Allows to download map tiles one by one
By default
tileDownloadingAllowed
= NO. GLMapView checks tile in world offline map first, then in embed and downloaded offline maps, then in downloaded earlier tiles and at last step if tile downloading is allowed it tries to download map tile.Declaration
Objective-C
@property BOOL tileDownloadingAllowed;
Swift
var tileDownloadingAllowed: Bool { get set }
-
Cached tile will be refreshed if it will stay in cache more than given time. Time interval is measured in seconds.
By default
tileRefreshTimeInterval
= -1. IftileRefreshTimeInterval
< 0 no tile refreshing will be triggered.Declaration
Objective-C
@property int64_t tileRefreshTimeInterval;
Swift
var tileRefreshTimeInterval: Int64 { get set }
-
Number of donwloded maps. World map is not counted as downloaded map.
Declaration
Objective-C
@property (readonly) NSInteger downloadedMapsCount;
Swift
var downloadedMapsCount: Int { get }
-
All tasks created by
[GLMapManager downloadMap:withCompletionBlock]
Map download task is removed from array when map downloading is finishedDeclaration
Objective-C
@property (readonly) NSArray<GLMapDownloadTask *> *_Nonnull allDownloadTasks;
Swift
var allDownloadTasks: [GLMapDownloadTask] { get }
-
Blocks what will called on the main thread when subtask is completed or cancelled.
Declaration
Objective-C
@property (strong) GLMapDownloadStatsBlock _Nullable downloadStatsBlock;
Swift
var downloadStatsBlock: GLMapDownloadStatsBlock? { get set }
-
Singleton manager object
Declaration
Objective-C
@property (class, nonatomic, readonly) GLMapManager *_Nonnull sharedManager;
Swift
class var shared: GLMapManager { get }
-
Bundle with resources
Declaration
Objective-C
@property (nonatomic, readonly) NSBundle *_Nonnull resourcesBundle;
Swift
var resourcesBundle: Bundle { get }
-
Updates map list
Declaration
Objective-C
- (void)updateMapListWithCompletionBlock:(GLMapListUpdateBlock _Nullable)block;
Swift
func updateMapList() async throws -> ([GLMapInfo], Bool)
Parameters
block
A block called when map list is downloaded
-
Updates downloaded maps. Call this after placing map data files to storage path.
Declaration
Objective-C
- (void)updateDownloadedMaps;
Swift
func updateDownloadedMaps()
-
Sorts maps by distance from border.
Declaration
Objective-C
- (void)sortMaps:(nonnull NSMutableArray<GLMapInfo *> *)maps fromPoint:(GLMapPoint)point;
Swift
func sortMaps(_ maps: NSMutableArray, from point: GLMapPoint)
Parameters
maps
maps to sort
point
point to meashure distance *
-
Deletes downloaded map data sets
Declaration
Objective-C
- (void)deleteDataSets:(GLMapInfoDataSetMask)dataSets forMap:(nonnull GLMapInfo *)map;
Swift
func deleteDataSets(_ dataSets: GLMapInfoDataSetMask, forMap map: GLMapInfo)
Parameters
dataSets
data sets to delete
map
map object
-
Starts download task
It’s up to you save download task or not. Active map download task could be received later from -downloadTaskForMap:.
Declaration
Objective-C
- (nonnull NSArray<GLMapDownloadTask *> *) downloadDataSets:(GLMapInfoDataSetMask)dataSets forMap:(nonnull GLMapInfo *)map withCompletionBlock:(GLMapDownloadCompletionBlock _Nullable)completionBlock;
Swift
func downloadDataSets(_ dataSets: GLMapInfoDataSetMask, forMap map: GLMapInfo, withCompletionBlock completionBlock: GLMapDownloadCompletionBlock? = nil) -> [GLMapDownloadTask]
Parameters
dataSets
data sets to download
map
map object
completionBlock
completion block
Return Value
A new download task object
-
Used to check if there is a download task for a given map
Declaration
Objective-C
- (GLMapDownloadTask *_Nullable)downloadTaskForMap:(nonnull GLMapInfo *)map dataSet:(GLMapInfoDataSet)dataSet;
Swift
func downloadTask(forMap map: GLMapInfo, dataSet: GLMapInfoDataSet) -> GLMapDownloadTask?
Parameters
map
A map info object
Return Value
Returns
GLMapDownloadTask
previously created for a map -
Used to check if there is a download task for a given map and data set
Declaration
Objective-C
- (NSArray<GLMapDownloadTask *> *_Nullable) downloadTasksForMap:(nonnull GLMapInfo *)map dataSets:(GLMapInfoDataSetMask)dataSets;
Swift
func downloadTasks(forMap map: GLMapInfo, dataSets: GLMapInfoDataSetMask) -> [GLMapDownloadTask]?
Parameters
map
A map info object
dataSets
data set to check
Return Value
Returns array of
GLMapDownloadTask
previously created for a map -
Downloads custom data set
Declaration
Objective-C
- (int64_t)downloadDataSet:(GLMapInfoDataSet)dataSet path:(nonnull NSString *)path bbox:(GLMapBBox)bbox progres:(nonnull GLMapDownloadProgress)progress completion:(nonnull GLMapDownloadCompletion)completion;
Swift
func downloadDataSet(_ dataSet: GLMapInfoDataSet, path: String, bbox: GLMapBBox, progres progress: @escaping GLMapDownloadProgress, completion: @escaping GLMapDownloadCompletion) -> Int64
Parameters
dataSet
Data set to download
path
Full path to file where to download data set
bbox
BBox of data to download
progress
Progress callback
completion
Completion callback
Return Value
taskID that can be used to cancel download
-
Cancels download by its task id
Declaration
Objective-C
- (void)cancelDownload:(int64_t)taskID;
Swift
func cancelDownload(_ taskID: Int64)
Parameters
taskID
id of the task to cancel
-
Cancels all downloads
Declaration
Objective-C
- (void)cancelAllDownloads;
Swift
func cancelAllDownloads()
-
Adds custom data set. Could be used for maps embed into the app resources. When map is added, it becomes available for all
GLMapView
objects.Declaration
Objective-C
- (GLMapError)addDataSet:(GLMapInfoDataSet)dataSet path:(nonnull NSString *)path bbox:(GLMapBBox)bbox;
Swift
func add(_ dataSet: GLMapInfoDataSet, path: String, bbox: GLMapBBox) -> GLMapError
Parameters
dataSet
Data set to add
path
Path to the data
bbox
BBox of data (can be empty)
Return Value
YES
if file is a valid data -
Removes custom data set from map manager. When removed is safe to delete data file.
Declaration
Objective-C
- (void)removeDataSet:(GLMapInfoDataSet)dataSet path:(nonnull NSString *)path;
Swift
func remove(_ dataSet: GLMapInfoDataSet, path: String)
Parameters
dataSet
Data set to remove
path
Path to the data
-
Finds custom data set at point
Declaration
Objective-C
- (NSArray<NSString *> *_Nullable)customDataSet:(GLMapInfoDataSet)dataSet atPoint:(GLMapPoint)point;
Swift
func customDataSet(_ dataSet: GLMapInfoDataSet, at point: GLMapPoint) -> [String]?
Parameters
dataSet
Data set to remove
point
Point to search
-
Returns map info with downloaded map data
Declaration
Objective-C
- (GLMapInfo *_Nullable)downloadedMapAtPoint:(GLMapPoint)point;
Swift
func downloadedMap(at point: GLMapPoint) -> GLMapInfo?
Parameters
point
Some point in internal format
Return Value
GLMapInfo
of downloaded map -
Returns map at given point
Declaration
Objective-C
- (NSArray<GLMapInfo *> *_Nullable)mapsAtPoint:(GLMapPoint)point;
Swift
func maps(at point: GLMapPoint) -> [GLMapInfo]?
Parameters
point
Some point in internal format
Return Value
GLMapInfo
of map -
Removes GLMap cached objects and closes opened databases
clearCaches
called automatically onUIApplicationDidEnterBackgroundNotification
Declaration
Objective-C
- (void)clearCaches;
Swift
func clearCaches()
-
Saves state for downloading tasks. It allows to resume downloads in case of crash or unexpected behavior
Called automatically when app is minimized
Declaration
Objective-C
- (void)saveDownloadsState;
Swift
func saveDownloadsState()
-
Returns vector tiles that bbox contains or intersects
Declaration
Objective-C
- (nonnull NSArray<NSNumber *> *)vectorTilesAtBBox:(GLMapBBox)bbox;
Swift
func vectorTiles(at bbox: GLMapBBox) -> [NSNumber]
Parameters
bbox
bbox of area
Return Value
Returns vector tiles array contained or intersected by bbox
-
Returns not cached vector tiles that bbox contains or intersects
Declaration
Objective-C
- (nonnull NSArray<NSNumber *> *)notCachedVectorTilesAtBBox:(GLMapBBox)bbox;
Swift
func notCachedVectorTiles(at bbox: GLMapBBox) -> [NSNumber]
Parameters
bbox
bbox of area
Return Value
Returns not cached vector tiles contained or intersected by bbox
-
Check if tiles cached. If not tile will be downloaded.
Declaration
Objective-C
- (void)cacheTiles:(nonnull NSArray<NSNumber *> *)tiles progressBlock:(GLMapTileDownloadProgressBlock _Nullable)progressBlock;
Swift
func cacheTiles(_ tiles: [NSNumber], progressBlock: GLMapTileDownloadProgressBlock? = nil)
Parameters
tiles
tiles to check
progressBlock
block that will be called when one tile is checked.
-
Enable fix of gcj coordinates to wgs *
Declaration
Objective-C
- (void)setNeedsChinaFix:(BOOL)needsChinaFix;
Swift
func setNeedsChinaFix(_ needsChinaFix: Bool)
-
The method is used to retrieve elevation and slope data for a given set of points.
Note
If either the elevation or slope parameters are NULL, the method will simply not fill in those values.
Declaration
Objective-C
- (BOOL)samplePoints:(nonnull GLMapGeoPoint *)points count:(NSInteger)count elevation:(float *_Nullable)elevation slope:(float *_Nullable)slope;
Swift
func samplePoints(_ points: UnsafeMutablePointer<GLMapGeoPoint>, count: Int, elevation: UnsafeMutablePointer<Float>?, slope: UnsafeMutablePointer<Float>?) -> Bool
Parameters
points
A pointer to an array of GLMapGeoPoint structures. Each structure specifies a point in geographical coordinates. This parameter must not be NULL.
count
The number of points in the array. This parameter can be zero.
elevation
A pointer to an array that the method fills in with the elevation data for each point, if not NULL. This is an output parameter.
slope
A pointer to an array that the method fills in with the slope data for each point, if not NULL. This is an output parameter.
Return Value
This method returns a BOOL value. If the method is successful, the return value is YES. If the method is not successful, the return value is NO.
-
Returns elevation at given point
Declaration
Objective-C
- (float)elevationAtPoint:(GLMapGeoPoint)point;
Swift
func elevation(at point: GLMapGeoPoint) -> Float
Parameters
point
location of elevation data
Return Value
elevation at point in meters or NAN if no downloaded data for this point
-
Asyncronys request of elevation
Declaration
Objective-C
- (void)elevationAtPoint:(GLMapGeoPoint)point completion:(nonnull GLMapFloatBlock)completion;
Swift
func elevation(at point: GLMapGeoPoint) async -> Float
Parameters
point
location of elevation data
completion
block that will be called on completion
-
Returns slope at given point
Declaration
Objective-C
- (float)slopeAtPoint:(GLMapGeoPoint)point;
Swift
func slope(at point: GLMapGeoPoint) -> Float
Parameters
point
location of slope data
Return Value
elevation at point in meters or NaN if no downloaded data for this point
-
Asyncronys request of elevation
Declaration
Objective-C
- (void)slopeAtPoint:(GLMapGeoPoint)point completion:(nonnull GLMapFloatBlock)completion;
Swift
func slope(at point: GLMapGeoPoint) async -> Float
Parameters
point
location of slope data
completion
block that will be called on completion