好吧,我遇到的问题是我有一个由指南针驱动iphone的覆盖。每当罗盘标题发生变化时,该线应在标题上移动。有两个叠加,一个用于指南针,另一个用于指南针。当只显示罗盘覆盖时,线条会随着变化而闪烁,但当显示另一条线时,闪烁消失,线条平滑移动。
- (MKOverlayView *)mapView:(MKMapView *)map viewForOverlay:(id <MKOverlay>)overlay
{
SatFinderAppDelegate *appdel = (SatFinderAppDelegate *)[[UIApplication sharedApplication]delegate];
float s = [appdel.location floatValue];
if (overlay == self.headingline)
{
headinglineView = [[MKPolylineView alloc] initWithPolyline:self.headingline];
headinglineView.fillColor = [UIColor greenColor];
headinglineView.strokeColor = [UIColor greenColor];
headinglineView.lineWidth = 5;
return self.headinglineView;
}
if (overlay == self.routeLine)
{
if (s == 0) {
return routeLineView = nil;
}
routeLineView = [[MKPolylineView alloc] initWithPolyline:self.routeLine];
routeLineView.fillColor = [UIColor cyanColor];
routeLineView.strokeColor = [UIColor cyanColor];
routeLineView.lineWidth = 5;
if (ele < 0) {
routeLineView.lineDashPattern = [NSArray arrayWithObjects:[NSNumber numberWithFloat:12],
[NSNumber numberWithFloat:8],nil];
routeLineView.strokeColor = [UIColor redColor];
}
return routeLineView;
}
return nil;
}
...
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading {
//line for heading
[self headinglineupdate];
}
...
-(void)headinglineupdate
{
[map removeOverlay:self.headingline];
self.headingline = nil;
self.headingline = [MKPolyline polylineWithCoordinates:locations count:2];
[map addOverlay:headingline];
[headinglineView setNeedsDisplay];
[map setNeedsDisplay];
}