MATileOverlay.h
2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//
// MATileOverlay.h
// MAMapKitNew
//
// Created by xiaoming han on 14-1-24.
// Copyright (c) 2014年 Amap. All rights reserved.
//
#import "MAOverlay.h"
///该类是覆盖在球面墨卡托投影上的图片tiles的数据源
@interface MATileOverlay : NSObject<MAOverlay>
/**
* @brief 根据指定的URLTemplate生成tileOverlay
* @param URLTemplate URLTemplate是一个包含"{x}","{y}","{z}","{scale}"的字符串,"{x}","{y}","{z}","{scale}"会被tile path的值所替换,并生成用来加载tile图片数据的URL 。例如 http://server/path?x={x}&y={y}&z={z}&scale={scale}
* @return 以指定的URLTemplate字符串生成tileOverlay
*/
- (instancetype)initWithURLTemplate:(NSString *)URLTemplate;
///默认tileSize 256x256
@property CGSize tileSize;
///overlay可以渲染的最小缩放级别。当0级时,一个tile覆盖整个世界范围,1级时覆盖 1/4th 世界,2级时1/16th,以此类推。
@property NSInteger minimumZ;
///overlay可以渲染的最大缩放级别。
@property NSInteger maximumZ;
///同initWithURLTemplate:中的URLTemplate
@property (readonly) NSString *URLTemplate;
///暂未开放
@property (nonatomic) BOOL canReplaceMapContent;
///区域外接矩形,可用来设定tileOverlay的可渲染区域
@property (nonatomic) MAMapRect boundingMapRect;
@end
///记录某特定tile的据结构。contentScaleFactor根据设备的ScrennScale而定, 为1.0或2.0。
struct MATileOverlayPath{
NSInteger x; ///< x坐标
NSInteger y; ///< y坐标
NSInteger z; ///< 缩放级别
CGFloat contentScaleFactor; ///< 屏幕的scale factor
};
typedef struct MATileOverlayPath MATileOverlayPath;
///子类可覆盖CustomLoading中的方法来自定义加载MATileOverlay的行为。
@interface MATileOverlay (CustomLoading)
/**
* @brief 以tile path生成URL。用于加载tile,此方法默认填充URLTemplate
* @param path tile path
* @return 以tile path生成tileOverlay
*/
- (NSURL *)URLForTilePath:(MATileOverlayPath)path;
/**
* @brief 加载被请求的tile,并以tile数据或加载tile失败error访问回调block;默认实现为首先用URLForTilePath去获取URL,然后用异步NSURLConnection加载tile
* @param path tile path
* @param result 用来传入tile数据或加载tile失败的error访问的回调block
*/
- (void)loadTileAtPath:(MATileOverlayPath)path result:(void (^)(NSData *tileData, NSError *error))result;
@end