diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2016-03-03 16:28:51 -0800 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2016-03-10 17:08:58 -0800 |
commit | 77657b38969a55377117dfde5fc9d5e3478208d1 (patch) | |
tree | 612ffa47975015efaa300a617e4d916a14e72688 /platform/darwin/include | |
parent | a65730803e4185600ff7251cf0a18a4835f4f41b (diff) | |
download | qtlocation-mapboxgl-77657b38969a55377117dfde5fc9d5e3478208d1.tar.gz |
[ios] Implemented offline API in iOS SDK
Fixes #3892.
Diffstat (limited to 'platform/darwin/include')
-rw-r--r-- | platform/darwin/include/MGLDownloadController.h | 30 | ||||
-rw-r--r-- | platform/darwin/include/MGLDownloadRegion.h | 13 | ||||
-rw-r--r-- | platform/darwin/include/MGLDownloadable.h | 49 | ||||
-rw-r--r-- | platform/darwin/include/MGLTilePyramidDownloadRegion.h | 19 | ||||
-rw-r--r-- | platform/darwin/include/MGLTypes.h | 7 |
5 files changed, 118 insertions, 0 deletions
diff --git a/platform/darwin/include/MGLDownloadController.h b/platform/darwin/include/MGLDownloadController.h new file mode 100644 index 0000000000..86bd1e6573 --- /dev/null +++ b/platform/darwin/include/MGLDownloadController.h @@ -0,0 +1,30 @@ +#import <Foundation/Foundation.h> + +#import "MGLTypes.h" + +NS_ASSUME_NONNULL_BEGIN + +@class MGLDownloadable; +@protocol MGLDownloadRegion; + +typedef void (^MGLDownloadableRegistrationCompletionHandler)(MGLDownloadable *downloadable, NSError *error); +typedef void (^MGLDownloadableRemovalCompletionHandler)(NSError *error); +typedef void (^MGLDownloadablesRequestCompletionHandler)(NS_ARRAY_OF(MGLDownloadable *) *downloadables, NSError *error); + +@interface MGLDownloadController : NSObject + ++ (instancetype)sharedController; + +- (instancetype)init NS_UNAVAILABLE; + +- (void)addDownloadableForRegion:(id <MGLDownloadRegion>)downloadRegion withContext:(NSData *)context completionHandler:(MGLDownloadableRegistrationCompletionHandler)completion; + +- (void)removeDownloadable:(MGLDownloadable *)downloadable withCompletionHandler:(MGLDownloadableRemovalCompletionHandler)completion; + +- (void)requestDownloadablesWithCompletionHandler:(MGLDownloadablesRequestCompletionHandler)completion; + +- (void)setMaximumAllowedMapboxTiles:(uint64_t)maximumCount; + +@end + +NS_ASSUME_NONNULL_END diff --git a/platform/darwin/include/MGLDownloadRegion.h b/platform/darwin/include/MGLDownloadRegion.h new file mode 100644 index 0000000000..5910c2117b --- /dev/null +++ b/platform/darwin/include/MGLDownloadRegion.h @@ -0,0 +1,13 @@ +#import <Foundation/Foundation.h> + +#import "MGLTypes.h" + +NS_ASSUME_NONNULL_BEGIN + +@protocol MGLDownloadRegion <NSObject> + +@property (nonatomic, readonly) NSURL *styleURL; + +@end + +NS_ASSUME_NONNULL_END diff --git a/platform/darwin/include/MGLDownloadable.h b/platform/darwin/include/MGLDownloadable.h new file mode 100644 index 0000000000..522a3c37ab --- /dev/null +++ b/platform/darwin/include/MGLDownloadable.h @@ -0,0 +1,49 @@ +#import <Foundation/Foundation.h> + +#import "MGLDownloadRegion.h" + +NS_ASSUME_NONNULL_BEGIN + +@protocol MGLDownloadableDelegate; + +typedef NS_ENUM (NSInteger, MGLDownloadableState) { + MGLDownloadableStateInactive = 0, + MGLDownloadableStateActive = 1, + MGLDownloadableStateComplete = 2, +}; + +typedef struct MGLDownloadableProgress { + uint64_t countOfResourcesCompleted; + uint64_t countOfBytesCompleted; + uint64_t countOfResourcesExpected; + uint64_t maximumResourcesExpected; +} MGLDownloadableProgress; + +@interface MGLDownloadable : NSObject + +@property (nonatomic, readonly) id <MGLDownloadRegion> region; +@property (nonatomic, readonly) NSData *context; +@property (nonatomic, readonly) MGLDownloadableState state; +@property (nonatomic, readonly) MGLDownloadableProgress progress; +@property (nonatomic, weak, nullable) id <MGLDownloadableDelegate> delegate; + +- (instancetype)init NS_UNAVAILABLE; + +- (void)resume; +- (void)suspend; + +- (void)requestProgress; + +@end + +@protocol MGLDownloadableDelegate <NSObject> + +@optional + +- (void)downloadable:(MGLDownloadable *)downloadable progressDidChange:(MGLDownloadableProgress)progress; +- (void)downloadable:(MGLDownloadable *)downloadable didReceiveError:(NSError *)error; +- (void)downloadable:(MGLDownloadable *)downloadable didReceiveMaximumAllowedMapboxTiles:(uint64_t)maximumCount; + +@end + +NS_ASSUME_NONNULL_END diff --git a/platform/darwin/include/MGLTilePyramidDownloadRegion.h b/platform/darwin/include/MGLTilePyramidDownloadRegion.h new file mode 100644 index 0000000000..6269775f19 --- /dev/null +++ b/platform/darwin/include/MGLTilePyramidDownloadRegion.h @@ -0,0 +1,19 @@ +#import <Foundation/Foundation.h> + +#import "MGLDownloadRegion.h" +#import "MGLGeometry.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface MGLTilePyramidDownloadRegion : NSObject <MGLDownloadRegion> + +@property (nonatomic, readonly) MGLCoordinateBounds bounds; +@property (nonatomic, readonly) double minimumZoomLevel; +@property (nonatomic, readonly) double maximumZoomLevel; + +- (instancetype)init NS_UNAVAILABLE; +- (instancetype)initWithStyleURL:(nullable NSURL *)styleURL bounds:(MGLCoordinateBounds)bounds fromZoomLevel:(double)minimumZoomLevel toZoomLevel:(double)maximumZoomLevel NS_DESIGNATED_INITIALIZER; + +@end + +NS_ASSUME_NONNULL_END diff --git a/platform/darwin/include/MGLTypes.h b/platform/darwin/include/MGLTypes.h index c107055dbb..213b90670e 100644 --- a/platform/darwin/include/MGLTypes.h +++ b/platform/darwin/include/MGLTypes.h @@ -15,6 +15,13 @@ NS_ASSUME_NONNULL_BEGIN /** Indicates an error occurred in the Mapbox SDK. */ extern NSString * const MGLErrorDomain; +typedef NS_ENUM(NSInteger, MGLErrorCode) { + MGLErrorCodeUnknown = -1, + MGLErrorCodeNotFound = 1, + MGLErrorCodeBadServerResponse = 2, + MGLErrorCodeConnectionFailed = 3, +}; + /** The mode used to track the user location on the map. */ typedef NS_ENUM(NSUInteger, MGLUserTrackingMode) { /** The map does not follow the user location. */ |