gpt4 book ai didi

ios - GMSTileURLConstructor 返回奇怪的缩放数据

转载 作者:可可西里 更新时间:2023-11-01 03:49:10 25 4
gpt4 key购买 nike

我正在尝试使用 GMSTileURLConstructor 在适用于 iOS 的 Google map 上绘制自定义叠加层.

我正在使用以下代码获取我的 URL

GMSTileURLConstructor urls = ^(NSUInteger x, NSUInteger y, NSUInteger zoom) {
NSString *url = @"";

for (NSDictionary *limits in [selectedPropertyMap objectForKey:@"property_map_zoom_levels"]) {
int zoomLevel = [[limits objectForKey:@"level"] intValue];
int tileMinX = 0;
int tileMaxX = 0;
int tileMinY = 0;
int tileMaxY = 0;

if ([limits objectForKey:@"tile_min_x"] != (id)[NSNull null]) {
tileMinX = [[limits objectForKey:@"tile_min_x"] intValue];
}
if ([limits objectForKey:@"tile_max_x"] != (id)[NSNull null]) {
tileMaxX = [[limits objectForKey:@"tile_max_x"] intValue];
}
if ([limits objectForKey:@"tile_min_y"] != (id)[NSNull null]) {
tileMinY = [[limits objectForKey:@"tile_min_y"] intValue];
}
if ([limits objectForKey:@"tile_max_y"] != (id)[NSNull null]) {
tileMaxY = [[limits objectForKey:@"tile_max_y"] intValue];
}

if (zoomLevel == (unsigned long)zoom) {
if ((tileMinX <= x) && (tileMaxX >= x) && (tileMinY <= y) && (tileMaxY >= y)) {
url = [NSString stringWithFormat:@"%@%@/%@/%@/%lu_%lu.png", MAP_URL, [property objectForKey:@"id"], [limits objectForKey:@"property_map_id"], [limits objectForKey:@"id"], (unsigned long)x, (unsigned long)y];
NSLog(@"url -> %@/zoom %lu/%i",url, (unsigned long)zoom, zoomLevel);
return [NSURL URLWithString:url];
}
}
}
return [NSURL URLWithString:url];
};

当我注销 URL、zoom 和 zoomLevel 时,我得到以下信息:

2014-05-16 17:25:15.621 Application[24491:61003] url -> <BASEURL>/16/9/19/159786_195303.png/zoom 19/19

同时,当相机变化时,我正在记录相机缩放

- (void)mapView:(GMSMapView *)mapView didChangeCameraPosition:(GMSCameraPosition *)position {
zoomLevelLabel.text = [NSString stringWithFormat:@"ZL: %.2f",position.zoom];
NSLog(@"camera changed - zoom %f",position.zoom);
[self hideMarkersBasedOnZoom:position.zoom];
if(position.zoom > 21) {
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:position.target.latitude longitude:position.target.longitude zoom:21];
[mapView_ setCamera:camera];
}
}

哪些日志

2014-05-16 17:25:15.640 Application[24491:60b] camera changed - zoom 18.022364

谁能解释缩放级别值的差异以及如何使其适当匹配?

最佳答案

在我做了一些研究之后,我相信 Google 处理 GMSTileLayer缩放级别 的方式与 mapView 的相机<的缩放级别不同.

GMSTileLayer 类引用

https://developers.google.com/maps/documentation/ios/reference/interface_g_m_s_tile_layer

At zoom level 0 the whole world is a square covered by a single tile, and the coordinates x and y are both 0 for that tile. At zoom level 1, the world is covered by 4 tiles with x and y being 0 or 1, and so on.

对于 mapView 相机

https://developers.google.com/maps/documentation/ios/views#zoom

The zoom level of the camera determines the scale of the map. At larger zoom levels more detail can be seen on the screen, while at smaller zoom levels more of the world can be seen on the screen. At zoom level 0, the scale of the map is such that the entire world has a width of approximately 256 points.

Increasing the zoom level by 1 doubles the width of the world on the screen. Hence at zoom level N, the width of the world is approximately 256 * 2N, i.e., at zoom level 2, the whole world is approximately 1024 points wide. Note that the zoom level need not be an integer. The range of zoom levels permitted by the map depends on a number of factors including location, map type and screen size.

GMSTileLayer 的缩放是 NSUIntegercamera 的缩放是 float。 GMSTileLayer 的缩放用于确定图 block 数量。而相机的变焦用于根据公式256 * 2N 确定点数

我可能是错的,但我认为两个缩放级别不匹配。

不太相关:Google 刚刚发布了 iOS Maps SDK V1.8.1,它解决了与 GMSTileLayer 相关的问题并修复了崩溃。

关于ios - GMSTileURLConstructor 返回奇怪的缩放数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23704961/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com