GLMapManager
Objective-C
@interface GLMapManager : NSObject
Swift
class GLMapManager : NSObject
Map Manager is used to work with the list of offline maps.
-
Activates the GLMap framework. Should be called before usage.
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?)
Parameters
apiKey
API key.
resourcesBundle
Bundle with framework resources: world.vm, fonts, and DefaultStyle.bundle. If
null
, uses the main bundle.storagePath
A path to the folder where offline maps are stored. If
null
, uses the documents folder. -
Unavailable
It’s a singleton object. Use
[GLMapManager sharedManager]
Default -init is disabled.
Declaration
Objective-C
- (nonnull instancetype)init;
-
A path to the folder where offline maps are stored.
Declaration
Objective-C
@property (strong) NSString *_Nonnull storagePath;
Swift
var storagePath: String { get set }
-
Path to the 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 downloading map tiles one by one. By default,
tileDownloadingAllowed
is set to NO. GLMapView checks the tile in the world offline map first, then in the embedded and downloaded offline maps, then in the downloaded earlier tiles, and finally, if tile downloading is allowed, it tries to download the map tile.Declaration
Objective-C
@property BOOL tileDownloadingAllowed;
Swift
var tileDownloadingAllowed: Bool { get set }
-
Cached tiles will be refreshed if they remain in the cache beyond the specified time interval. This interval is measured in seconds. By default,
tileRefreshTimeInterval
is set to 2,592,000 seconds (30 days). IftileRefreshTimeInterval
is less than 0, no tile refreshing will be triggered. Note: Tiles will continue to operate offline even after the refresh interval has passed, although the framework will attempt to download them again.Declaration
Objective-C
@property int64_t tileRefreshTimeInterval;
Swift
var tileRefreshTimeInterval: Int64 { get set }
-
Number of downloaded maps. The world map is not counted as a downloaded map.
Declaration
Objective-C
@property (readonly) NSInteger downloadedMapsCount;
Swift
var downloadedMapsCount: Int { get }
-
All tasks created by
[GLMapManager downloadMap:withCompletionBlock]
. The map download task is removed from the array when the map downloading is finished.Declaration
Objective-C
@property (readonly) NSArray<GLMapDownloadTask *> *_Nonnull allDownloadTasks;
Swift
var allDownloadTasks: [GLMapDownloadTask] { get }
-
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 the map list.
Declaration
Objective-C
- (void)updateMapListWithCompletionBlock:(GLMapListUpdateBlock _Nullable)block;
Swift
func updateMapList() async throws -> ([GLMapInfo], Bool)
Parameters
block
A block called when the map list is downloaded.
-
Updates downloaded maps. Call this after placing map data files in the storage path.
Declaration
Objective-C
- (void)updateDownloadedMaps;
Swift
func updateDownloadedMaps()
-
Sorts maps by distance from the 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 measure the 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 the download task. It’s up to you to save the download task or not. The active map download task can be retrieved 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 an 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 progress:(nonnull GLMapDownloadProgress)progress completion:(nonnull GLMapDownloadCompletion)completion;
Swift
func downloadDataSet(_ dataSet: GLMapInfoDataSet, path: String, bbox: GLMapBBox, progress: @escaping GLMapDownloadProgress, completion: @escaping GLMapDownloadCompletion) -> Int64
Parameters
dataSet
Data set to download.
path
Full path to the file where to download the data set.
bbox
BBox of data to download.
progress
Progress callback.
completion
Completion callback.
Return Value
TaskID that can be used to cancel the download.
-
Cancels the 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 a custom data set. Can be used for maps embedded into the app resources. When a 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 the file is a valid data. -
Removes a custom data set from the map manager. When removed, it is safe to delete the 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 a custom data set at a 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 the internal format.
Return Value
GLMapInfo
of the downloaded map. -
Returns the map at a given point.
Declaration
Objective-C
- (NSArray<GLMapInfo *> *_Nullable)mapsAtPoint:(GLMapPoint)point;
Swift
func maps(at point: GLMapPoint) -> [GLMapInfo]?
Parameters
point
Some point in the internal format.
Return Value
GLMapInfo
of the map. -
Removes GLMap cached objects and closes opened databases.
clearCaches
is called automatically onUIApplicationDidEnterBackgroundNotification
.Declaration
Objective-C
- (void)clearCaches;
Swift
func clearCaches()
-
Saves the state for downloading tasks. It allows resuming downloads in case of a crash or unexpected behavior. Called automatically when the app is minimized.
Declaration
Objective-C
- (void)saveDownloadsState;
Swift
func saveDownloadsState()
-
Returns vector tiles that the bbox contains or intersects.
Declaration
Objective-C
- (nonnull NSArray<NSNumber *> *)vectorTilesAtBBox:(GLMapBBox)bbox;
Swift
func vectorTiles(at bbox: GLMapBBox) -> [NSNumber]
Parameters
bbox
BBox of the area.
Return Value
Returns a vector tiles array contained or intersected by the 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 the area.
Return Value
Returns not cached vector tiles contained or intersected by the bbox.
-
Checks if tiles are cached. If not, the 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.
-
Enables the 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 the elevation at a 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 the point in meters or NAN if no downloaded data for this point.
-
Asynchronous request for 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 the slope at a given point.
Declaration
Objective-C
- (float)slopeAtPoint:(GLMapGeoPoint)point;
Swift
func slope(at point: GLMapGeoPoint) -> Float
Parameters
point
Location of slope data.
Return Value
Slope at the point in meters or NaN if no downloaded data for this point.
-
Asynchronous request for slope.
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.