GMSTileLayer.h 3.5 KB

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