简体   繁体   English

GMSMapView初始绘图失败

[英]GMSMapView Initial drawing fails

I am creating GMSMapView instance as subview in custom UIView using following code 我正在使用以下代码在自定义UIView中将GMSMapView实例创建为子视图

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:position.latitude
                                                        longitude:position.latitude
                                                             zoom:CAMZOOM];

if(camera)
{
    self.googleMapView =  [GMSMapView mapWithFrame:self.frame camera:camera];
    self.googleMapView.myLocationEnabled = YES;
    self.googleMapView.delegate=self;

} }

I am adding multiple UIbutton and GMSMarker to this view , which are visible without any issue but often I get map draws like below (occurs) 我向此视图添加了多个UIbutton和GMSMarker,这些都是可见的,没有任何问题,但通常我会得到如下图所示的地图绘制(发生)

错误绘制的GMSMapView

I have button which triggers animation to current location (refer following code), map is drawn without any issue 我有一个按钮可以触发动画到当前位置(请参阅以下代码),绘制地图时没有任何问题

[self.googleMapView animateToLocation:self.googleMapView.myLocation.coordinate];

Fixed 固定

After I removed view animation (alpha 0.0 to 1.0 with duration 1 sec) , this issue got fixed. 在删除视图动画(持续时间1秒的alpha值从0.0到1.0)之后,此问题已解决。 Now my map instance loads with flicker but I can live with that. 现在,我的地图实例会闪烁,但我可以忍受。

Your coordinates are null so what you are seeing is blue ocean and the values are latitude = 0.0 and longitude =0.0. 您的坐标为空,因此您看到的是蓝色海洋,值是纬度= 0.0和经度= 0.0。 Try setting the coodinates manually by assigning some known value to see it it works. 尝试通过分配一些已知值来手动设置coodinates,以查看其工作原理。 Eventually you need to learn how to use the delegates to read the cordinates when it becomes available. 最终,您需要学习如何在可用时使用委托来读取坐标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM