为什么MKTileOverlay initWithURLTemplate:template返回nil?

时间:2014-09-16 06:01:53

标签: ios mapkit mktileoverlay

我有一个如下代码:

- (void)viewDidLoad
{
[super viewDidLoad];

NSString* template = [NSString stringWithFormat: @"http://my-map-server.com/?mode=tile&tilemode=gmap&tile={x}+{y}+{z}"] ;

MKTileOverlay * overlay = [[MKTileOverlay alloc] initWithURLTemplate:template]; //returns nil
overlay.canReplaceMapContent = NO;

[mainMap addOverlay:overlay1 level:MKOverlayLevelAboveLabels];

}

为什么[[MKTileOverlay alloc] initWithURLTemplate:template]返回nil值?我无法找到任何合理的解决方案。类似的代码可以在我的其他项目中使用。

1 个答案:

答案 0 :(得分:0)

  

此模板字符串应包含{x}{y}{z}{scale}占位符字符串,以便于创建用于请求相应图块的网址。

如果您将{scale}添加到模板中,您会得到相同的结果吗?