0

I'm using GMSMapView for an iPad app. I want to display custom tiles in the map but I couldn't.

I've created custom TileLayer.h

#import <GoogleMaps/GoogleMaps.h>
  @interface TileLayer : GMSSyncTileLayer
@end

and TileLayer.m

#import "TileLayer.h"
@implementation TileLayer
-(UIImage *) tileForX:(NSUInteger)x y:(NSUInteger)y zoom:(NSUInteger)zoom {
    NSLog(@"tile");
}
@end

in the MainView.m

viewMap.mapType = kGMSTypeNone;    
GMSTileURLConstructor urls = ^(NSUInteger x, NSUInteger y, NSUInteger zoom) {
        NSString *url = [NSString stringWithFormat:@"http://www.example.com/images/tile/%d_%d_%d.jpg",zoom,x,y];
        return [NSURL URLWithString:url];
    };
    GMSURLTileLayer *layer = [GMSURLTileLayer tileLayerWithURLConstructor:urls];
    layer.zIndex = 100;
    layer.map = viewMap;

NSLog command never executed. What is wrong?

Ufuk Ugur
  • 186
  • 1
  • 17

1 Answers1

0

Yours TileLayer is never called. If you like to use your custom class:

    layer = [[TileLayer alloc] init]
    layer.map = mapView

GMSURLTileLayer is another approach for adding custom tiles.

Roman Barzyczak
  • 3,785
  • 1
  • 30
  • 44