【问题标题】:iOS Google map SDK: Setting maxZoom level issue when using TilesiOS Google 地图 SDK:使用 Tiles 时设置 maxZoom 级别问题
【发布时间】:2014-12-23 01:14:34
【问题描述】:

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

见下面的例子(这个来自 Google SDKDemo Example,我只是把 URL 改成指向我的域):

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 版

【问题讨论】:

    标签: ios google-maps


    【解决方案1】:

    我认为 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,camera的缩放为float。GMSTileLayer的缩放用于确定tile的数量。而camera的缩放用于根据公式256确定点的数量* 2N."*

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-04
      • 2016-04-10
      相关资源
      最近更新 更多