OGeek|极客世界-中国程序员成长平台

标题: ios - map 路线 View 未正确显示 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 18:07
标题: ios - map 路线 View 未正确显示

我实现了一个 map ,它运行良好。但是当我尝试放大 map 时,我看到了这个问题:

enter image description here

这是我的代码:

-(MKAnnotationView *)mapViewMKMapView *)mapView viewForAnnotationid<MKAnnotation>)annotation
{
    MKAnnotationView* annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier"LocationPin"];
    if ([annotation isEqual:self.startLocation]) {
        annotationView.image = [UIImage imageNamed"startPin.png"];
        return annotationView;
    } else if ([annotation isEqual:self.endLocation]){
        annotationView.image = [UIImage imageNamed"endPin.png"];
        return annotationView;
    }

    return nil;
}

- (MKOverlayRenderer *)mapViewMKMapView *)mapView rendererForOverlayid<MKOverlay>)overlay {
    @autoreleasepool {
        if ([overlay isKindOfClass:[MKPolyline class]]) {
            MKPolylineRenderer *renderer = [[MKPolylineRenderer alloc] initWithOverlayverlay];
            [renderer setStrokeColor:kColor_Magenta];
            [renderer setLineWidth:4.0];
            return renderer;
        }
        return nil;
    }

}



Best Answer-推荐答案


这可能与缩放时重绘折线有关。检查这个答案。 Zoom MKMapView to fit polyline points

关于ios - map 路线 View 未正确显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40777494/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4