|
是,一开始是显示大头针并且没有连线,等按了home键再返回annotation也显示正常,连线也显示正常了。
是不是和ViewForAnnotation的实现没关呢,就是self.mapView.delegate的问题吧?
viewForAnnotation的实现如下
- - (MAAnnotationView *)mapView:(MAMapView *)mapView viewForAnnotation:(id<MAAnnotation>)annotation
- {
- if ([annotation isKindOfClass:[LocationPointAnnotation class]]) {
- static NSString *reuseIndetifier = @"startAnnotationReuseIndetifier";
- RouteHistoryAnnotationView *annotationView = (RouteHistoryAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:reuseIndetifier];
- if (annotationView == nil) {
- annotationView = [[RouteHistoryAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:reuseIndetifier];
- }
- // must set to NO, so we can show the custom callout view.
- annotationView.canShowCallout = NO;
- annotationView.draggable = NO;
- annotationView.calloutOffset = CGPointMake(0, 0);
- LocationPointAnnotation *locationPointAnnotation = annotation;
- if (annotation == _startLocation) {
- // annotationView.image = [UIImage imageNamed:@"history_setstart_@2x"];
- annotationView.portrait = [UIImage imageNamed:@"history_setstart_@2x"];
- } else if (annotation == _destinationPoint){
- // annotationView.image = [UIImage imageNamed:@"history_setend_@2x"];
- annotationView.portrait = [UIImage imageNamed:@"history_setend_@2x"];
- } else {
- // annotationView.image = [UIImage imageNamed:@"history_Arrow_right@2x"];
- annotationView.portrait = [UIImage imageNamed:@"history_Arrow_right@2x"];
- }
- annotationView.mainLabelValue = locationPointAnnotation.location.mainAddress;
- annotationView.subLabelValue = locationPointAnnotation.location.subAddress;
- NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
- [dateFormatter setDateFormat:@"MM-dd HH:mm"];
- [dateFormatter setTimeZone:[NSTimeZone systemTimeZone]];
- NSString *_gen_time = [dateFormatter stringFromDate:[[NSDate alloc] initWithTimeIntervalSince1970:[locationPointAnnotation.location.gen_time doubleValue]]];
- annotationView.dateLabelValue = _gen_time;
- annotationView.radian = locationPointAnnotation.radian;
- return annotationView;
- }
- return nil;
- }
复制代码 |
|