iOS Google Map SDK:使用Tiles时设置maxZoom级别问题 [英] iOS Google map SDK: Setting maxZoom level issue when using Tiles

查看:147
本文介绍了iOS Google Map SDK:使用Tiles时设置maxZoom级别问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将示例的最大缩放级别设置为19时,我会注意到,当我使用图块时,缩放比例会升至20.我不知道为什么总是比我设置的缩放级别高1级.

I notice when I set the max Zoom level of example to 19, the zoom go up to 20 when I'm using tiles. I don't know why. It's always 1 more zoom level than the one I set.

请参见下面的示例(此示例来自Google SDKDemo,我只是将URL更改为指向我的域):

See below example (This from Google SDKDemo Example, I just changed URL to point to my domain):

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_;

现在,如果我继续放大.我将打印日志:

Now, if I kept zoom in. I will get the log printed:

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

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

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

Notice, the zoom level after the domain is 20 although, the max I set it to 19. Notice, I'm using Google SDK version 1.9

推荐答案

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

I think the zoom in GMSTileURLConstructor is different from the zoom in MapView.

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

I tried to put the some NSLog inside the GMSTileURLConstructor block, like the following:

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

我认为此答案可能会对您有所帮助.

I think this answer might help you.

答案部分:

*"GMSTileLayer的缩放比例为NSUInteger,而摄像机的缩放比例为浮动.GMSTileLayer的缩放比例用于确定切片的数量.而摄像机的缩放比例基于公式256确定点的数量* 2N."*

*"The zoom for GMSTileLayer is NSUInteger while the zoom for camera is float. The zoom for GMSTileLayer is used to determine the number of tiles. While the zoom for camera is used to determine the number of points based on the formula 256 * 2N."*

这篇关于iOS Google Map SDK:使用Tiles时设置maxZoom级别问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆