GMSTileLayer.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. //
  2. // GMSTileLayer.h
  3. // Google Maps SDK for iOS
  4. //
  5. // Copyright 2013 Google Inc.
  6. //
  7. // Usage of this SDK is subject to the Google Maps/Google Earth APIs Terms of
  8. // Service: https://developers.google.com/maps/terms
  9. //
  10. #if __has_feature(modules)
  11. @import GoogleMapsBase;
  12. #else
  13. #import <GoogleMapsBase/GoogleMapsBase.h>
  14. #endif
  15. @class GMSMapView;
  16. GMS_ASSUME_NONNULL_BEGIN
  17. /**
  18. * Stub tile that is used to indicate that no tile exists for a specific tile
  19. * coordinate. May be returned by tileForX:y:zoom: on GMSTileProvider.
  20. */
  21. FOUNDATION_EXTERN UIImage *const kGMSTileLayerNoTile;
  22. /**
  23. * GMSTileReceiver is provided to GMSTileLayer when a tile request is made,
  24. * allowing the callback to be later (or immediately) invoked.
  25. */
  26. @protocol GMSTileReceiver<NSObject>
  27. - (void)receiveTileWithX:(NSUInteger)x
  28. y:(NSUInteger)y
  29. zoom:(NSUInteger)zoom
  30. image:(UIImage *GMS_NULLABLE_PTR)image;
  31. @end
  32. /**
  33. * GMSTileLayer is an abstract class that allows overlaying of custom image
  34. * tiles on a specified GMSMapView. It may not be initialized directly, and
  35. * subclasses must implement the tileForX:y:zoom: method to return tiles.
  36. *
  37. * At zoom level 0 the whole world is a square covered by a single tile,
  38. * and the coordinates |x| and |y| are both 0 for that tile. At zoom level 1,
  39. * the world is covered by 4 tiles with |x| and |y| being 0 or 1, and so on.
  40. */
  41. @interface GMSTileLayer : NSObject
  42. /**
  43. * requestTileForX:y:zoom:receiver: generates image tiles for GMSTileOverlay.
  44. * It must be overridden by subclasses. The tile for the given |x|, |y| and
  45. * |zoom| _must_ be later passed to |receiver|.
  46. *
  47. * Specify kGMSTileLayerNoTile if no tile is available for this location; or
  48. * nil if a transient error occured and a tile may be available later.
  49. *
  50. * Calls to this method will be made on the main thread. See GMSSyncTileLayer
  51. * for a base class that implements a blocking tile layer that does not run on
  52. * your application's main thread.
  53. */
  54. - (void)requestTileForX:(NSUInteger)x
  55. y:(NSUInteger)y
  56. zoom:(NSUInteger)zoom
  57. receiver:(id<GMSTileReceiver>)receiver;
  58. /**
  59. * Clears the cache so that all tiles will be requested again.
  60. */
  61. - (void)clearTileCache;
  62. /**
  63. * The map this GMSTileOverlay is displayed on. Setting this property will add
  64. * the layer to the map. Setting it to nil removes this layer from the map. A
  65. * layer may be active on at most one map at any given time.
  66. */
  67. @property(nonatomic, weak) GMSMapView *GMS_NULLABLE_PTR map;
  68. /**
  69. * Higher |zIndex| value tile layers will be drawn on top of lower |zIndex|
  70. * value tile layers and overlays. Equal values result in undefined draw
  71. * ordering.
  72. */
  73. @property(nonatomic, assign) int zIndex;
  74. /**
  75. * Specifies the number of pixels (not points) that the returned tile images
  76. * will prefer to display as. For best results, this should be the edge
  77. * length of your custom tiles. Defaults to 256, which is the traditional
  78. * size of Google Maps tiles.
  79. *
  80. * Values less than the equivalent of 128 points (e.g. 256 pixels on retina
  81. * devices) may not perform well and are not recommended.
  82. *
  83. * As an example, an application developer may wish to provide retina tiles
  84. * (512 pixel edge length) on retina devices, to keep the same number of tiles
  85. * per view as the default value of 256 would give on a non-retina device.
  86. */
  87. @property(nonatomic, assign) NSInteger tileSize;
  88. /**
  89. * Specifies the opacity of the tile layer. This provides a multiplier for
  90. * the alpha channel of tile images.
  91. */
  92. @property(nonatomic, assign) float opacity;
  93. /**
  94. * Specifies whether the tiles should fade in. Default YES.
  95. */
  96. @property(nonatomic, assign) BOOL fadeIn;
  97. @end
  98. GMS_ASSUME_NONNULL_END