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
apiKeyAPI key.
resourcesBundleBundle with framework resources: world.vm, fonts, and DefaultStyle.bundle. If
null, uses the main bundle.storagePathA 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,
tileDownloadingAllowedis 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,
tileRefreshTimeIntervalis set to 2,592,000 seconds (30 days). IftileRefreshTimeIntervalis 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 } -
Blocks that will be called on the main thread when the subtask is completed or canceled.
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 the map list.
Declaration
Objective-C
- (void)updateMapListWithCompletionBlock:(GLMapListUpdateBlock _Nullable)block;Swift
func updateMapList() async throws -> ([GLMapInfo], Bool)Parameters
blockA 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
mapsMaps to sort.
pointPoint 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
dataSetsData sets to delete.
mapMap 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
dataSetsData sets to download.
mapMap object.
completionBlockCompletion 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
mapA map info object.
Return Value
Returns
GLMapDownloadTaskpreviously 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
mapA map info object.
dataSetsData set to check.
Return Value
Returns an array of
GLMapDownloadTaskpreviously 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) -> Int64Parameters
dataSetData set to download.
pathFull path to the file where to download the data set.
bboxBBox of data to download.
progressProgress callback.
completionCompletion 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
taskIDID 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
GLMapViewobjects.Declaration
Objective-C
- (GLMapError)addDataSet:(GLMapInfoDataSet)dataSet path:(nonnull NSString *)path bbox:(GLMapBBox)bbox;Swift
func add(_ dataSet: GLMapInfoDataSet, path: String, bbox: GLMapBBox) -> GLMapErrorParameters
dataSetData set to add.
pathPath to the data.
bboxBBox of data (can be empty).
Return Value
YESif 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
dataSetData set to remove.
pathPath 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
dataSetData set to remove.
pointPoint 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
pointSome point in the internal format.
Return Value
GLMapInfoof 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
pointSome point in the internal format.
Return Value
GLMapInfoof the map. -
Removes GLMap cached objects and closes opened databases.
clearCachesis 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
bboxBBox 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
bboxBBox 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
tilesTiles to check.
progressBlockBlock 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>?) -> BoolParameters
pointsA pointer to an array of GLMapGeoPoint structures. Each structure specifies a point in geographical coordinates. This parameter must not be NULL.
countThe number of points in the array. This parameter can be zero.
elevationA pointer to an array that the method fills in with the elevation data for each point, if not NULL. This is an output parameter.
slopeA 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) -> FloatParameters
pointLocation 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 -> FloatParameters
pointLocation of elevation data.
completionBlock 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) -> FloatParameters
pointLocation 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 -> FloatParameters
pointLocation of slope data.
completionBlock that will be called on completion.
Install in Dash
GLMapManager Class Reference