ios - GMSTileURLConstructor Returns Strange Data for Zoom -


i trying draw custom overlay on google maps ios using gmstileurlconstructor.

i using following code url

gmstileurlconstructor urls = ^(nsuinteger x, nsuinteger y, nsuinteger zoom) {         nsstring *url = @"";          (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];     }; 

when log out url, zoom , zoomlevel following information:

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

at same time, logging camera zoom when camera changes

- (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];     } } 

which logs

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

can explain discrepancy in zoom level value , how have match appropriately?

after did research, believe way google handles zoom level gmstilelayer not same zoom level camera of mapview.

gmstilelayer class reference

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

at zoom level 0 whole world square covered single tile, , coordinates x , y both 0 tile. @ zoom level 1, world covered 4 tiles x , y being 0 or 1, , on.

for mapview camera

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

the zoom level of camera determines scale of map. @ larger zoom levels more detail can seen on screen, while @ smaller zoom levels more of world can seen on screen. @ zoom level 0, scale of map such entire world has width of approximately 256 points.

increasing zoom level 1 doubles width of world on screen. hence @ zoom level n, width of world approximately 256 * 2n, i.e., @ zoom level 2, whole world approximately 1024 points wide. note zoom level need not integer. range of zoom levels permitted map depends on number of factors including location, map type , screen size.

the zoom gmstilelayer nsuinteger while zoom camera float. zoom gmstilelayer used determine number of tiles. while zoom camera used determine number of points based on formula 256 * 2n.

i wrong think both zoom levels not matched up.

not related: google released ios maps sdk v1.8.1 solved issue related gmstilelayer , fixed crash.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -