iOS Google地图SDK:使用Tiles时设置maxZoom级别问题

时间:2014-12-22 16:16:40

标签: ios google-maps

我注意到当我将示例的最大缩放级别设置为19时,当我使用切片时,缩放最多为20。我不知道为什么。它总是比我设置的缩放级别多一个。

请参阅下面的示例(这来自Google SDKDemo示例,我刚刚将网址更改为指向我的域名):

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:23.614328
                                                          longitude:58.545284
                                                               zoom:18];

  mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];

   [mapView_ setMinZoom:5 maxZoom:19];
  //mapView_.buildingsEnabled = NO;
  //mapView_.indoorEnabled = NO;
    mapView_.mapType = kGMSTypeHybrid;
  self.view = mapView_;

 tileLayer_.map = nil;

    // Create a new GMSTileLayer with the new floor choice.
    GMSTileURLConstructor urls = ^(NSUInteger x, NSUInteger y, NSUInteger zoom) {
      NSString *url = [NSString stringWithFormat:@"http://www.example.com/%tu/%tu/%tu.png",  zoom, x, y];
       NSLog(@"URL: %@",url);
      return [NSURL URLWithString:url];
    };
    tileLayer_ = [GMSURLTileLayer tileLayerWithURLConstructor:urls];
    tileLayer_.map = mapView_;

现在,如果我继续放大。我会打印日志:

2014-12-22 20:06:02.342 SDKDemos [1792:941894]网址:http://www.example.com/20/694778/453520.png

请注意,域后的缩放级别为20,但最大值我将其设置为19。 请注意,我使用的是Google SDK 1.9版

1 个答案:

答案 0 :(得分:2)

我认为GMSTileURLConstructor中的缩放与MapView中的缩放不同。

我试图将一些NSLog放在GMSTileURLConstructor块中,如下所示:

GMSTileURLConstructor urls = ^(NSUInteger x, NSUInteger y, NSUInteger zoom) {
        NSString *url = [NSString stringWithFormat:@"http://www.example.com/%tu/%tu/%tu.png",  zoom, x, y];
        NSLog(@"URL: %@",url);
        NSLog(@"max zoom: %f", mapView_.maxZoom);
        NSLog(@"max tileLayer zoom: %f", tileLayer_.map.maxZoom);
        return [NSURL URLWithString:url];
    };

打印

2014-12-22 08:56:07.959 HelloMap[30797:1797670] max zoom: 19.000000
2014-12-22 08:56:07.959 HelloMap[30797:1797670] max tileLayer zoom: 19.000000

我认为this answer可能对您有帮助。

部分答案:

*" GMSTileLayer的缩放是NSUInteger,而相机的缩放是浮动的。 GMSTileLayer的缩放用于确定切片的数量。而相机的变焦用于根据公式256 * 2N确定点数。" *

相关问题