iOS Google地图SDK:设置maxZoom级别问题

时间:2014-12-05 18:51:20

标签: ios google-maps google-maps-api-3

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

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:23.589571946369546
                                                        longitude:58.14204730042655
                                                             zoom:16];

self.mapView_.camera=camera;
self.mapView_.myLocationEnabled = YES;


self.mapView_.mapType = kGMSTypeHybrid;
self.mapView_.settings.compassButton = YES;
[self.mapView_ setMinZoom:5 maxZoom:19];



// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(23.168520, 58.008163);

marker.map = self.mapView_;
// ------ add layer
// Implement GMSTileURLConstructor
// Returns a Tile based on the x,y,zoom coordinates, and the requested floor
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];
};

1 个答案:

答案 0 :(得分:2)

你怎么知道maxZoom是20?您使用的是哪个版本的iOS Maps SDK?

我尝试了Google地图中的示例hello map application'使用iOS Maps SDK版本1.9.1的Github页面,并将以下代码放在videDidLoad()方法中。它打印出正确的最大变焦值19。

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:23.589571946369546
                                                            longitude:58.14204730042655
                                                                 zoom:16];

    mapView_.camera=camera;
    mapView_.myLocationEnabled = YES;

    mapView_.mapType = kGMSTypeHybrid;
    mapView_.settings.compassButton = YES;

    // Create the GMSMapView with the camera position.
    mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];

    [mapView_ setMinZoom:5 maxZoom:19];

    NSLog(@"max zoom: %f", mapView_.maxZoom);