diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2017-02-17 12:18:49 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2017-02-20 14:36:27 +0100 |
commit | 6c0310209de9d6721d6fb9391c43df6cb9962e22 (patch) | |
tree | 1c67720cdc6b4fad7ebc637a8ae24ef3658e2f0a /platform/darwin/src/MGLOfflineStorage.h | |
parent | 03a14ff0003e976a4ded70d284bc80adf54bc6c9 (diff) | |
download | qtlocation-mapboxgl-6c0310209de9d6721d6fb9391c43df6cb9962e22.tar.gz |
[macos,ios] expose callback for transforming URLs
Diffstat (limited to 'platform/darwin/src/MGLOfflineStorage.h')
-rw-r--r-- | platform/darwin/src/MGLOfflineStorage.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/platform/darwin/src/MGLOfflineStorage.h b/platform/darwin/src/MGLOfflineStorage.h index 2d376c9222..16f134adb1 100644 --- a/platform/darwin/src/MGLOfflineStorage.h +++ b/platform/darwin/src/MGLOfflineStorage.h @@ -7,6 +7,7 @@ NS_ASSUME_NONNULL_BEGIN @class MGLOfflinePack; @protocol MGLOfflineRegion; +@protocol MGLOfflineStorageDelegate; /** Posted by the shared `MGLOfflineStorage` object when an `MGLOfflinePack` @@ -132,6 +133,30 @@ typedef void (^MGLOfflinePackAdditionCompletionHandler)(MGLOfflinePack * _Nullab typedef void (^MGLOfflinePackRemovalCompletionHandler)(NSError * _Nullable error); /** + The type of resource that is requested. + */ +typedef NS_ENUM(NSUInteger, MGLResourceKind) { + /** Unknown type */ + MGLResourceKindUnknown, + /** Style sheet JSON file */ + MGLResourceKindStyle, + /** TileJSON file as specified in https://www.mapbox.com/mapbox-gl-js/style-spec/#root-sources */ + MGLResourceKindSource, + /** A vector or raster tile as described in the style sheet at + https://www.mapbox.com/mapbox-gl-js/style-spec/#sources */ + MGLResourceKindTile, + /** Signed distance field glyphs for text rendering. These are the URLs specified in the style + in https://www.mapbox.com/mapbox-gl-js/style-spec/#root-glyphs */ + MGLResourceKindGlyphs, + /** Image part of a sprite sheet. It is constructed of the prefix in + https://www.mapbox.com/mapbox-gl-js/style-spec/#root-sprite and a PNG file extension. */ + MGLResourceKindSpriteImage, + /** JSON part of a sprite sheet. It is constructed of the prefix in + https://www.mapbox.com/mapbox-gl-js/style-spec/#root-sprite and a JSON file extension. */ + MGLResourceKindSpriteJSON, +}; + +/** MGLOfflineStorage implements a singleton (shared object) that manages offline packs. All of this class’s instance methods are asynchronous, reflecting the fact that offline resources are stored in a database. The shared object @@ -145,6 +170,20 @@ MGL_EXPORT */ + (instancetype)sharedOfflineStorage; +#pragma mark - Accessing the Delegate + +/** + The receiver’s delegate. + + An offline storage object sends messages to its delegate to allow it to + transform URLs before they are requested from the internet. This can be used + add or remove custom parameters, or reroute certain requests to other servers + or endpoints. + */ +@property(nonatomic, weak, nullable) IBOutlet id<MGLOfflineStorageDelegate> delegate; + +#pragma mark - Managing Offline Packs + /** An array of all known offline packs, in the order in which they were created. @@ -250,4 +289,25 @@ MGL_EXPORT @end +/** + The `MGLOfflineStorageDelegate` protocol defines methods that a delegate of an + `MGLOfflineStorage` object can optionally implement to transform various types + of URLs before downloading them via the internet. + */ +@protocol MGLOfflineStorageDelegate <NSObject> + +/** + Sent whenever a URL needs to be transformed. + + @param storage The storage object processing the download. + @param kind The kind of URL to be transformed. + @param url The original URL to be transformed. + @return A URL that will now be downloaded. + */ +- (NSURL *)offlineStorage:(MGLOfflineStorage *)storage + URLForResourceOfKind:(MGLResourceKind)kind + withURL:(NSURL *)url; + +@end + NS_ASSUME_NONNULL_END |