You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

163 lines
6.0 KiB

//
// MAOfflineMap.h
//
// Copyright (c) 2013年 Amap. All rights reserved.
//
#import "MAConfig.h"
#if MA_INCLUDE_OFFLINE
#import <Foundation/Foundation.h>
#import "MAOfflineProvince.h"
#import "MAOfflineItemNationWide.h"
#import "MAOfflineItemMunicipality.h"
///离线地图下载状态
typedef NS_ENUM(NSInteger, MAOfflineMapDownloadStatus)
{
MAOfflineMapDownloadStatusWaiting = 0, //!< 以插入队列,等待中
MAOfflineMapDownloadStatusStart, //!< 开始下载
MAOfflineMapDownloadStatusProgress, //!< 下载过程中
MAOfflineMapDownloadStatusCompleted, //!< 下载成功
MAOfflineMapDownloadStatusCancelled, //!< 取消
MAOfflineMapDownloadStatusUnzip, //!< 解压缩
MAOfflineMapDownloadStatusFinished, //!< 全部顺利完成
MAOfflineMapDownloadStatusError //!< 发生错误
};
///离线下载错误domain
extern NSString * const MAOfflineMapErrorDomain;
///离线地图下载错误类型
typedef NS_ENUM(NSInteger, MAOfflineMapError)
{
MAOfflineMapErrorUnknown = -1, //!< 未知的错误
MAOfflineMapErrorCannotWriteToTmp = -2, //!< 写入临时目录失败
MAOfflineMapErrorCannotOpenZipFile = -3, //!< 打开归档文件失败
MAOfflineMapErrorCannotExpand = -4 //!< 解归档文件失败
};
/**
* downloadStatus == MAOfflineMapDownloadStatusProgress , info参数是个NSDictionary,
* key用来获取已下载和总和的数据大小(byte), NSNumber(long long) .
* downloadStatus == MAOfflineMapDownloadStatusError , info参数是NSError
*/
///下载过程info的key,表示已下载数据大小
extern NSString * const MAOfflineMapDownloadReceivedSizeKey;
///下载过程info的key,表示总的数据大小
extern NSString * const MAOfflineMapDownloadExpectedSizeKey;
/**
* @brief 线block
* @param downloadItem item
* @param downloadStatus
* @param info
*/
typedef void(^MAOfflineMapDownloadBlock)(MAOfflineItem * downloadItem, MAOfflineMapDownloadStatus downloadStatus, id info);
/**
* @brief 线block
* @param hasNewestVersion
*/
typedef void(^MAOfflineMapNewestVersionBlock)(BOOL hasNewestVersion);
///离线地图管理类
@interface MAOfflineMap : NSObject
/**
* @brief MAOfflineMap
* @return MAOfflineMap
*/
+ (MAOfflineMap *)sharedOfflineMap;
///省份数组(每个元素均是MAOfflineProvince类型)
@property (nonatomic, readonly) NSArray<MAOfflineProvince *> *provinces;
///直辖市数组(每个元素均是MAOfflineItemMunicipality类型)
@property (nonatomic, readonly) NSArray<MAOfflineItemMunicipality *> *municipalities;
///全国概要图
@property (nonatomic, readonly) MAOfflineItemNationWide *nationWide;
///城市数组, 包括普通城市与直辖市
@property (nonatomic, readonly) NSArray<MAOfflineCity *> *cities;
///离线数据的版本号(由年月日组成, 如@"20130715")
@property (nonatomic, readonly) NSString *version;
/**
* @brief 线offlinePackage.plist文件不存在MAOfflineMap中的省
* @param block
*/
- (void)setupWithCompletionBlock:(void(^)(BOOL setupSuccess))block;
/**
* @brief
* @param item
* @param shouldContinueWhenAppEntersBackground
* @param downloadBlock block
*/
- (void)downloadItem:(MAOfflineItem *)item shouldContinueWhenAppEntersBackground:(BOOL)shouldContinueWhenAppEntersBackground downloadBlock:(MAOfflineMapDownloadBlock)downloadBlock;
/**
* @brief
* @param item
* @return
*/
- (BOOL)isDownloadingForItem:(MAOfflineItem *)item;
/**
* @brief
* @param item
* @return cancelitem并未在下载中NO
*/
- (BOOL)pauseItem:(MAOfflineItem *)item;
/**
* @brief item对应离线地图数据
* @param item
*/
- (void)deleteItem:(MAOfflineItem *)item;
/**
* @brief
*/
- (void)cancelAll;
/**
* @brief 线, [mapView reloadMap]使
*/
- (void)clearDisk;
/**
* @brief provincesmunicipalitiesnationWidecities使newestVersionBlock中更新所持有的对象
* @param newestVersionBlock block
*/
- (void)checkNewestVersion:(MAOfflineMapNewestVersionBlock)newestVersionBlock;
@end
@interface MAOfflineMap (Deprecated)
///deprecated
@property (nonatomic, readonly) NSArray *offlineCities __attribute__ ((deprecated("use cities instead")));
///deprecated
- (void)downloadCity:(MAOfflineCity *)city downloadBlock:(MAOfflineMapDownloadBlock)downloadBlock __attribute__ ((deprecated("use - (void)downloadItem:(MAOfflineItem *)item shouldContinueWhenAppEntersBackground:(BOOL)shouldContinueWhenAppEntersBackground downloadBlock:(MAOfflineMapDownloadBlock)downloadBlock instead")));
///deprecated
- (void)downloadCity:(MAOfflineCity *)city shouldContinueWhenAppEntersBackground:(BOOL)shouldContinueWhenAppEntersBackground downloadBlock:(MAOfflineMapDownloadBlock)downloadBlock __attribute__ ((deprecated("use - (void)downloadItem:(MAOfflineItem *)item shouldContinueWhenAppEntersBackground:(BOOL)shouldContinueWhenAppEntersBackground downloadBlock:(MAOfflineMapDownloadBlock)downloadBlock instead")));
///deprecated
- (BOOL)isDownloadingForCity:(MAOfflineCity *)city __attribute__ ((deprecated("use - (BOOL)isDownloadingForItem:(MAOfflineItem *)item instead")));
///deprecated
- (void)pause:(MAOfflineCity *)city __attribute__ ((deprecated("use - (void)pauseItem:(MAOfflineItem *)item instead")));
@end
#endif