本文介绍了如何在mapView中添加折线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我会在地图视图中插入一条折线! 我是用这种方式做到的
I would insert in my mapview an polyline! I made it in this way
CLLocationCoordinate2D coord[2]; coord[1].latitude = 45.42207; coord[1].longitude = 9.123888; coord[2].latitude = 45.422785; coord[2].longitude = 9.12377; MKPolyline *polyline = [[MKPolyline alloc] init]; polyline = [MKPolyline polylineWithCoordinates:coord count:2]; [self.mapView addAnnotation:polyline];但是不起作用,并出现以下错误:EXC_BAD_ACCESS. 怎么了?
But don't work and there's this error: EXC_BAD_ACCESS. What's it wrong?
推荐答案尝试一下
CLLocationCoordinate2D coord[2]; coord[0].latitude = 45.42207; coord[0].longitude = 9.123888; coord[1].latitude = 45.422785; coord[1].longitude = 9.12377; MKPolyline *polyline = [[MKPolyline alloc] init]; polyline = [MKPolyline polylineWithCoordinates:coord count:2]; - (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay { MKPolylineView *polyLineView = [[MKPolylineView alloc] initWithPolyline:polyline]; polyLineView.fillColor = [UIColor blueColor]; polyLineView.strokeColor = [UIColor greenColor]; polyLineView.lineWidth = 7; return polyLineView; }更多推荐
如何在mapView中添加折线
发布评论