jjzjj

MKPolyLine

全部标签

ios - Swift:子类 MKPolyline

我正在开发一个请求多个方向(MKDirectionsRequest)并在mapView中绘制路线的应用程序,一切正常。但我面临一个问题:我想用不同的颜色绘制每条路线。第一个想法很简单:使用标题/副标题来“标记”不同的MKPolyline,这样我就可以在委托(delegate)函数中设置我想要的颜色:mapView(_mapView:MKMapView,rendererForoverlay:MKOverlay)->MKOverlayRenderer但我不喜欢这个解决方案,因为它“丑陋”,而且我将不得不在必须传递不同参数(交通..)的那一天解析一个字符串第二个简单的解决方案是将MKPoly

swift - 如何在 Mapkit 中绘制两条不同颜色的多段线?

这是我绘制第一条线的代码,对于另一种颜色的另一条线,我该怎么办?????funcmapView(mapView:MKMapView!,rendererForOverlayoverlay:MKOverlay!)->MKOverlayRenderer!{ifoverlayisMKPolyline{varpolyLineRenderer=MKPolylineRenderer(overlay:overlay)polyLineRenderer.strokeColor=UIColor.blackColor()polyLineRenderer.lineWidth=10returnpolyLineRe

ios - 平滑 MKPolyline 跟随道路

我知道几年前有人问过这个问题,但所有答案都涉及使用GoogleMapsAPI来解决这个问题。我想知道现在iOS8已经出来并且它为原生MapKit带来了许多改进,是否有适当的方法来解决这个问题。基本上我在路上画了一条折线,它由许多中间点组成。varlocations=[CLLocation]()foriteminlist{locations.append(CLLocation(latitude:CLLocationDegrees(item["location"]["coordinate"]["x"].doubleValue),longitude:CLLocationDegrees(ite

ios - 在 MapView 上渲染多条折线

我有两组坐标并试图在mapView上绘制多段线。我可以用一组坐标绘制多段线,但无法绘制两条多段线。下面是代码...funcdrawRouteOnMap(){varcenterCoordinate:CLLocationCoordinate2D=CLLocationCoordinate2DMake(icRouteLat[0],icRouteLong[0])letspan=MKCoordinateSpanMake(0.001,0.001)varcenterPosition=MKCoordinateRegionMake(centerCoordinate,span)mapView.setRegi

swift - MKPolyLine 没有出现在 Swift 的 MapView 上

我在Swift中有以下代码,用于将MKPolyline添加到MapView。XCode没有告诉我有问题,据我所知,这应该有效。MapView的导出:@IBOutletweakvarmapView:MKMapView!保存坐标的变量:varcoordinates:[CLLocationCoordinate2D]=[]从CoreData获取我保存的坐标:varcontextMap=(UIApplication.sharedApplication().delegateasAppDelegate).managedObjectContext!varrequestMap=NSFetchReques

ios - MKPolylineRenderer 产生锯齿状、不相等的路径

我正在使用iOS7MapKitAPI在显示MKDirectionsRequest生成的路径的map上生成3D相机移动。路径由MKOverlayRenderer渲染,如下所示:-(void)showRoute:(MKDirectionsResponse*)response{for(MKRoute*routeinresponse.routes){[self.mapaddOverlay:route.polylinelevel:MKOverlayLevelAboveRoads];}}-(MKOverlayRenderer*)mapView:(MKMapView*)mapViewrenderer

ios - MKPolylineRenderer 产生锯齿状、不相等的路径

我正在使用iOS7MapKitAPI在显示MKDirectionsRequest生成的路径的map上生成3D相机移动。路径由MKOverlayRenderer渲染,如下所示:-(void)showRoute:(MKDirectionsResponse*)response{for(MKRoute*routeinresponse.routes){[self.mapaddOverlay:route.polylinelevel:MKOverlayLevelAboveRoads];}}-(MKOverlayRenderer*)mapView:(MKMapView*)mapViewrenderer

ios - 使用 MKPolylineRenderer 创建 MKMapSnapshotter

我认为iOS7的MKMapSnapshotter将是拍摄MKMapView快照的简单方法,好处是您可以在不将map加载到View中的情况下执行此操作.尽管添加图钉和叠加层似乎需要更多工作(因为需要核心图形)。WWDC视频提供了一个很好的示例,说明如何通过添加MKAnnotationView创建MKMapSnapshotter。但是,对于核心图形经验不多的人来说,如何从MKPolylineRenderer创建MKMapSnapshotter并不是很明显。我试过这样做,但是路径不准确。它准确地绘制了大约10%的线,但随后绘制了笔直的路径的其余部分。这是我的代码:MKMapSnapshott

ios - 使用 MKPolylineRenderer 创建 MKMapSnapshotter

我认为iOS7的MKMapSnapshotter将是拍摄MKMapView快照的简单方法,好处是您可以在不将map加载到View中的情况下执行此操作.尽管添加图钉和叠加层似乎需要更多工作(因为需要核心图形)。WWDC视频提供了一个很好的示例,说明如何通过添加MKAnnotationView创建MKMapSnapshotter。但是,对于核心图形经验不多的人来说,如何从MKPolylineRenderer创建MKMapSnapshotter并不是很明显。我试过这样做,但是路径不准确。它准确地绘制了大约10%的线,但随后绘制了笔直的路径的其余部分。这是我的代码:MKMapSnapshott

ios - map View 上的虚线

我可以用下面的代码很容易地在两点之间创建一条线(无论如何都是它的一部分)我怎样才能使线变成虚线而不是实线?还有,线越长,是否可以改变不透明度?-(MKOverlayRenderer*)mapView:(MKMapView*)mapViewrendererForOverlay:(id)overlay{MKPolylineRenderer*renderer=[[MKPolylineRendereralloc]initWithPolyline:overlay];renderer.strokeColor=[UIColororangeColor];renderer.lineWidth=3.0;r