ios – Google地图折线不完美呈现

我正在使用最新的Google Maps API for iOS绘制折线.我正在逐点构造折线,但是当我缩小折线从地图中消失(不是字面上的术语)时,它不能正常渲染,当我放大时,它只会显示线条.


这是放大时折线的显示方式


这是缩小时的显示方式

这里是我绘制折线的功能

RCpolyline *polyline = [[RCpolyline alloc] init];
[polyline drawpolylineFromPoint:self.selectedEmployee.location toPoint:location];

我有覆盖init:为RCpolyline是这样的东西

- (instancetype)init {
self = [super init];
if (self) {
    self.strokeWidth = 5.0f;
    self.strokeColor = UIColor.redColor;
    self.geodesic = YES;
    self.map = [RCMapView sharedMapView];
}
return self;}

和drawpolylineFromPoint:toPoint:这样做

- (void)drawpolylineFromPoint:(CLLocation *)pointX toPoint:(CLLocation *)pointY {
      GMSMutablePath *path = [GMSMutablePath path];
      [path addCoordinate:pointX.coordinate];
      [path addCoordinate:pointY.coordinate];
      self.path = path;}

解决方法

我发现这个故障,我正在制作RCpolyline类的本地实例,并且正在调用构建折线的方法,我想要的是为RCpolyline实例提供一个全局对象,并为RCpolyline类实例更新GMSPath

这样的:

- (instancetype)initWithMap:(GMSMapView *)mapView {
    self = [super init];
    if (self) {
      self.strokeWidth = 4.0f;
      self.strokeColor = [UIColor redColor];
      self.geodesic = YES;
      self.map = mapView;
      self.mutablePath = [GMSMutablePath path];
    }
      return self;}

现在我从同一个实例调用这个方法.

- (void)appendpolylineWithCoordinate:(CLLocation *)location {
    [self.mutablePath addCoordinate:location.coordinate];
    self.path = self.mutablePath;}

PS:RCpolyline是GMSpolyline的子类

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...