我正在使用最新的Google Maps API for iOS绘制折线。我正在逐点构建折线,但当我缩小地图时,折线从地图中消失(不是字面意义上的消失),而当我放大时,它只会显示直线。
以下是我的绘制折线的函数:
RCPolyline *polyline = [[RCPolyline alloc] init];
[polyline drawPolylineFromPoint:self.selectedEmployee.location toPoint:location];
我已经重写了RCPolyline的init:
方法,使其类似于这样
- (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;}