GMSURLTileLayer Class Reference


Overview

GMSURLTileProvider fetches tiles based on the URLs returned from a GMSTileURLConstructor.

For example:

   GMSTileURLConstructor constructor = ^(NSUInteger x, NSUInteger y, NSUInteger zoom) {
     NSString *URLStr =
         [NSString stringWithFormat:"https://example.com/%d/%d/%d.png", x, y, zoom];
     return [NSURL URLWithString:URLStr];
   };
   GMSTileLayer *layer =
       [GMSURLTileLayer tileLayerWithURLConstructor:constructor];
   layer.userAgent = "SDK user agent";
   layer.map = map;
 

GMSURLTileProvider may not be subclassed and should only be created via its convenience constructor.

Inherits GMSTileLayer.

Public Member Functions

(void) - requestTileForX:y:zoom:receiver:
 requestTileForX:y:zoom:receiver: generates image tiles for GMSTileOverlay.
(void) - clearTileCache
 Clears the cache so that all tiles will be requested again.

Static Public Member Functions

(instancetype) + tileLayerWithURLConstructor:
 Convenience constructor.

Properties

NSString * userAgent
 Specify the user agent to describe your application.
GMSMapViewmap
 The map this GMSTileOverlay is displayed on.
int zIndex
 Higher zIndex value tile layers will be drawn on top of lower zIndex value tile layers and overlays.
NSInteger tileSize
 Specifies the number of pixels (not points) that the returned tile images will prefer to display as.
float opacity
 Specifies the opacity of the tile layer.
BOOL fadeIn
 Specifies whether the tiles should fade in.

(Note that these are not member functions.)

typedef NSURL *_Nullable(^ GMSTileURLConstructor )(NSUInteger x, NSUInteger y, NSUInteger zoom)
 GMSTileURLConstructor is a block taking x, y and zoom and returning an NSURL, or nil to indicate no tile for that location.

Member Function Documentation

+ (instancetype) tileLayerWithURLConstructor: (GMSTileURLConstructor constructor

Convenience constructor.

constructor must be non-nil.

- (void) requestTileForX: (NSUInteger)  x
y: (NSUInteger)  y
zoom: (NSUInteger)  zoom
receiver: (id< GMSTileReceiver >)  receiver 

requestTileForX:y:zoom:receiver: generates image tiles for GMSTileOverlay.

It must be overridden by subclasses. The tile for the given x, y and zoom _must_ be later passed to receiver.

Specify kGMSTileLayerNoTile if no tile is available for this location; or nil if a transient error occurred and a tile may be available later.

Calls to this method will be made on the main thread. See GMSSyncTileLayer for a base class that implements a blocking tile layer that does not run on your application's main thread.

- (void) clearTileCache

Clears the cache so that all tiles will be requested again.


- (typedef NSURL* _Nullable(^ GMSTileURLConstructor)(NSUInteger x, NSUInteger y, NSUInteger zoom)) [related]

GMSTileURLConstructor is a block taking x, y and zoom and returning an NSURL, or nil to indicate no tile for that location.


Property Documentation

- (NSString*) userAgent [read, write, copy]

Specify the user agent to describe your application.

If this is nil (the default), the default iOS user agent is used for HTTP requests.

- (GMSMapView*) map [read, write, assign, inherited]

The map this GMSTileOverlay is displayed on.

Setting this property will add the layer to the map. Setting it to nil removes this layer from the map. A layer may be active on at most one map at any given time.

- (int) zIndex [read, write, assign, inherited]

Higher zIndex value tile layers will be drawn on top of lower zIndex value tile layers and overlays.

Equal values result in undefined draw ordering.

- (NSInteger) tileSize [read, write, assign, inherited]

Specifies the number of pixels (not points) that the returned tile images will prefer to display as.

For best results, this should be the edge length of your custom tiles. Defaults to 256, which is the traditional size of Google Maps tiles.

Values less than the equivalent of 128 points (e.g. 256 pixels on retina devices) may not perform well and are not recommended.

As an example, an application developer may wish to provide retina tiles (512 pixel edge length) on retina devices, to keep the same number of tiles per view as the default value of 256 would give on a non-retina device.

- (float) opacity [read, write, assign, inherited]

Specifies the opacity of the tile layer.

This provides a multiplier for the alpha channel of tile images.

- (BOOL) fadeIn [read, write, assign, inherited]

Specifies whether the tiles should fade in.

Default YES.