AI-generated Key Takeaways
-
GMSURLTileLayerfetches map tiles using URLs provided by aGMSTileURLConstructor. -
You can customize the user agent for HTTP requests made by the tile layer.
-
It's easily initialized using a convenience constructor that takes a
GMSTileURLConstructorto define how tile URLs are generated. -
GMSURLTileProvidercannot be subclassed and should only be created using its designated constructor.
GMSURLTileLayer
@interface GMSURLTileLayer : GMSTileLayerGMSURLTileProvider 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.
-
Convenience constructor.
constructormust be non-nil.Declaration
Swift
convenience init(urlConstructor constructor: @escaping GMSTileURLConstructor)Objective-C
+ (nonnull instancetype)tileLayerWithURLConstructor: (nonnull GMSTileURLConstructor)constructor; -
Specify the user agent to describe your application. If this is nil (the default), the default iOS user agent is used for HTTP requests.
Declaration
Swift
var userAgent: String? { get set }Objective-C
@property (nonatomic, copy, nullable) NSString *userAgent;