如何在mapView中添加折线

编程入门 行业动态 更新时间:2024-10-22 04:56:29
本文介绍了如何在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中添加折线

本文发布于:2023-06-07 22:01:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/568549.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:折线   如何在   mapView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!