MATileOverlay.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // MATileOverlay.h
  3. // MapKit_static
  4. //
  5. // Created by Li Fei on 11/22/13.
  6. // Copyright © 2016 Amap. All rights reserved.
  7. //
  8. #import "MAConfig.h"
  9. #if MA_INCLUDE_OVERLAY_TILE
  10. #import "MAOverlay.h"
  11. ///该类是覆盖在球面墨卡托投影上的图片tiles的数据源
  12. @interface MATileOverlay : NSObject <MAOverlay>
  13. ///瓦片大小,默认是256x256, 最小支持64*64
  14. @property (nonatomic, assign) CGSize tileSize;
  15. ///tileOverlay的可见最小Zoom值
  16. @property NSInteger minimumZ;
  17. ///tileOverlay的可见最大Zoom值
  18. @property NSInteger maximumZ;
  19. ///同initWithURLTemplate:中的URLTemplate
  20. @property (readonly) NSString *URLTemplate;
  21. ///暂未开放
  22. @property (nonatomic) BOOL canReplaceMapContent;
  23. ///区域外接矩形,可用来设定tileOverlay的可渲染区域
  24. @property (nonatomic) MAMapRect boundingMapRect;
  25. ///是否停止不在显示区域内的瓦片下载,默认NO. since 5.3.0
  26. @property (nonatomic, assign) BOOL disableOffScreenTileLoading;
  27. /**
  28. * @brief 根据指定的URLTemplate生成tileOverlay
  29. * @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}
  30. * @return 以指定的URLTemplate字符串生成tileOverlay
  31. */
  32. - (id)initWithURLTemplate:(NSString *)URLTemplate;
  33. @end
  34. ///MATileOverlayPath
  35. struct MATileOverlayPath{
  36. NSInteger x; ///< x坐标
  37. NSInteger y; ///< y坐标
  38. NSInteger z; ///< 缩放级别
  39. CGFloat contentScaleFactor; ///< 屏幕的scale factor
  40. };
  41. typedef struct MATileOverlayPath MATileOverlayPath;
  42. ///子类可覆盖CustomLoading中的方法来自定义加载MATileOverlay的行为。
  43. @interface MATileOverlay (CustomLoading)
  44. /**
  45. * @brief 以tile path生成URL。用于加载tile,此方法默认填充URLTemplate
  46. * @param path tile path
  47. * @return 以tile path生成tileOverlay
  48. */
  49. - (NSURL *)URLForTilePath:(MATileOverlayPath)path;
  50. /**
  51. * @brief 加载被请求的tile,并以tile数据或加载tile失败error访问回调block;默认实现为首先用URLForTilePath去获取URL,然后用异步NSURLConnection加载tile
  52. * @param path tile path
  53. * @param result 用来传入tile数据或加载tile失败的error访问的回调block
  54. */
  55. - (void)loadTileAtPath:(MATileOverlayPath)path result:(void (^)(NSData *tileData, NSError *error))result;
  56. /**
  57. * @brief 取消请求瓦片,当地图显示区域发生变化时,会取消显示区域外的瓦片的下载, 当disableOffScreenTileLoading=YES时会被调用。since 5.3.0
  58. * @param path tile path
  59. */
  60. - (void)cancelLoadOfTileAtPath:(MATileOverlayPath)path;
  61. @end
  62. #endif