mkpolyline

MKPolyline strange rendering related with zooming in MapKit

送分小仙女□ 提交于 2019-12-03 03:32:30
I have very simple View Controller to demonstrate this strange rendering behavior of MKPolyline. Nothing special just normal api calls. import UIKit import MapKit class ViewController: UIViewController, MKMapViewDelegate { @IBOutlet weak var map: MKMapView! override func viewDidLoad() { super.viewDidLoad() map.delegate = self } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) let p1 = CLLocationCoordinate2D(latitude: 51, longitude: 13) var coords = [ p1, CLLocationCoordinate2D(latitude: 51.1, longitude: 13), CLLocationCoordinate2D(latitude: 51.2, longitude: 13),

How to make custom MKPolyline in SWIFT with additional argument - color

做~自己de王妃 提交于 2019-12-01 17:38:20
Can any help me with making custom MKPolyline with additional argument Color? CustomPolyline.swift import Foundation import MapKit class CustomPolyline : MKPolyline { let coordinates: UnsafeMutablePointer<CLLocationCoordinate2D> let count : Int = 0 let color : String = "ff0000" init(coordinates: UnsafeMutablePointer<CLLocationCoordinate2D>, count: Int, color: String) { self.coordinates = coordinates self.count = count self.color = color } } Init Polyline = CustomPolyline(coordinates: &Path, count: Path.count, color: "ff0000") self.mapView.addOverlay(Polyline) func mapView(mapView: MKMapView!,

How to store an MKPolyline attribute as transformable in IOS coredata with swift?

偶尔善良 提交于 2019-12-01 04:15:27
What would be the code required to allow the storage of an MKPolyline in CoreData in swift. So for example if I had one of my core data entities (say "myEntity") for which I wanted to save an MKPolyline, and have added the "polyline" field as transformable, and have set it to "transformable" in xcode. Also have produced NSManagedObject subclass. myEntity.swift import UIKit import CoreData import MapKit class myEntity: NSManagedObject { } myEntity+CoreDataProperties.swift import Foundation import CoreData extension myEntity { @NSManaged var title: String @NSManaged var polyline: NSObject? }

Creating an MKMapSnapshotter with an MKPolylineRenderer

╄→尐↘猪︶ㄣ 提交于 2019-12-01 03:03:06
I thought iOS 7's MKMapSnapshotter s would be a simple way to take a snapshot of an MKMapView , the benefit is that you can do it without loading the map into view. Even though it seems like more work to add pins and overlays (because of the need for core graphics). The WWDC videos give a very good example of creating an MKMapSnapshotter with adding an MKAnnotationView . However, for someone with not a lot of core graphics experience it's not really obvious how you create an MKMapSnapshotter from an MKPolylineRenderer . I have tried to do this, but the path is inaccurate. It draws about 10% of

Creating an MKMapSnapshotter with an MKPolylineRenderer

♀尐吖头ヾ 提交于 2019-11-30 22:56:10
问题 I thought iOS 7's MKMapSnapshotter s would be a simple way to take a snapshot of an MKMapView , the benefit is that you can do it without loading the map into view. Even though it seems like more work to add pins and overlays (because of the need for core graphics). The WWDC videos give a very good example of creating an MKMapSnapshotter with adding an MKAnnotationView . However, for someone with not a lot of core graphics experience it's not really obvious how you create an MKMapSnapshotter

MKPolyline / MKPolylineRenderer changing color without remove it

怎甘沉沦 提交于 2019-11-30 14:16:07
I working around with map app, I want to ask how to change the polyline color without remove and add it again, I found this topic https://stackoverflow.com/questions/24226290/mkpolylinerenderer-change-color-without-removing-overlay in stackoverflow but this is not involve with my question, I did not touch the line, so no need to do with -[MKMapViewDelegate mapView:didSelectAnnotationView:] So is it possible to do that? EDIT: What I want to do is change the polyline color smoothly (by shading a color - sound like an animation) If you have any idea on how to animate this polyline please also

Touch events on MKMapView's overlays

一曲冷凌霜 提交于 2019-11-30 09:09:21
In the app I'm currently designing I have a MKMapView with overlays on it (customized MKPolylines btw) and I would like to be able to detect touch events on these overlays and assign a specific action to each overlay. Could any one help me on this one ? Thanks ! Benja Jano This can be solved combining How to intercept touches events on a MKMapView or UIWebView objects? and How to determine if an annotation is inside of MKPolygonView (iOS) . Add this in viewWillAppear: WildcardGestureRecognizer * tapInterceptor = [[WildcardGestureRecognizer alloc] init]; tapInterceptor.touchesBeganCallback = ^

Gradient along MKPolyLineView ( MKPolylineRenderer )

限于喜欢 提交于 2019-11-30 09:03:24
I'd like to apply a gradient on a polyline view depending on some conditions like speed. I was able to subclass MKPolyLineRenderer to draw with custom stroke and fill, but only with the same color along the path. I saw other similar questions like : Draw segments from a circle or donut or On OSX, how do I gradient fill a path stroke? , but it is not exactly what I'd want. If I understand correctly, a path like below couldn't be filled with these methods. At least not treated as a whole. A very similar question is Gradient Polyline with MapKit ios . But it adds an overlay for each segment

UnsafeMutablePointer in swift as replacement for properly sized C Array in Obj-C

喜你入骨 提交于 2019-11-30 04:49:06
How can I interact with functions in swift that used to take sized C arrays? I read through Interacting with C APIS and still can't figure this out. The documentation for the coords parameter of func getCoordinates(_ coords:UnsafeMutablePointer<CLLocationCoordinate2D>,range range: NSRange) states: "On input, you must provide a C array of structures large enough to hold the desired number of coordinates. On output, this structure contains the requested coordinate data." I tried several things, most recently: var coordinates: UnsafeMutablePointer<CLLocationCoordinate2D> = nil polyline

Gradient along MKPolyLineView ( MKPolylineRenderer )

久未见 提交于 2019-11-29 12:58:59
问题 I'd like to apply a gradient on a polyline view depending on some conditions like speed. I was able to subclass MKPolyLineRenderer to draw with custom stroke and fill, but only with the same color along the path. I saw other similar questions like : Draw segments from a circle or donut or On OSX, how do I gradient fill a path stroke? , but it is not exactly what I'd want. If I understand correctly, a path like below couldn't be filled with these methods. At least not treated as a whole. A