我有一个项目,我已经实现了facebook风格的侧滚动菜单。我想要完成的是通过在侧面菜单上按一个按钮在地图视图控制器中使用GMSTileURLConstructor来调用方法,在下面的Google Map上加载一些额外的图层,但无论采用何种方法(尝试过segue和target动作)块代码不会被执行。如果我在地图ViewController上添加一个按钮,它可以正常工作。
更新 问题似乎是即使从SideViewController(滑块)调用该方法,GMSTileURLConstructor也不会在块中获取x,y和z值,并且不会执行。
大概是因为MapView无法计算屏幕的界限,因为它部分被滑块覆盖???测试时使用:
GMSCoordinateBounds *bounds= [[GMSCoordinateBounds alloc] initWithRegion:_mapView.projection.visibleRegion];
NSLog(@" x:%f, y:%f", bounds.northEast.latitude, bounds.southWest.latitude);
始终返回0.000000和0.00000000
答案 0 :(得分:0)
当有人按下侧面菜单上的按钮时,您可以尝试[[NSNotificationCenter defaultCenter] postNotificationWithName:@"somename" object:self];
。
然后在地图视图控制器中,收听通知:[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleSomenameNotification:) name:@"somename" object:nil];
然后您可以在handleSomenameNotification:
方法中加载额外的图层。此外,记得在完成该视图控制器时将自己删除为该通知的观察者。