在我的应用程序中,我使用 MKPolyline 来跟踪用户的路径。有时(不是一直,我不明白),当新的线段被添加到地图时,整条线都会闪烁。有时它不会。这是用于添加行的代码:
CLLocationCoordinate2D coords[2];
coords[0] = CLLocationCoordinate2DMake(newLocation.coordinate.latitude, newLocation.coordinate.longitude);
coords[1] = CLLocationCoordinate2DMake(oldLocation.coordinate.latitude, oldLocation.coordinate.longitude);
MKPolyline* line = [MKPolyline polylineWithCoordinates:coords count:2];
[mapView addOverlay:line];
我错过了什么吗?
编辑:这通常发生在应用程序从被发送到后台返回时。不过,我不确定为什么,因为我只是添加了一个叠加层,而不是修改整个 mapView.overlays 数组。...对?