Questions tagged [mkpolyline]

MKPolyline is used to represent a sequence of connected points, commonly used to draw an overlay on a MKMapView.

MKPolyline is used to represent a sequence of connected points, commonly used to draw an overlay on a MKMapView. Note that the first and last points are not automatically linked by a segment and that the order of the points does matter.

MKPolylines are almost always used in conjunction with an MKPolylineView, which is responsible for the user interface representation on a map.

For more information, please refer to the Apple Documentation for MKPolyline and MKPolylineView.

Related tags:

177 questions
31
votes
2 answers

latitude and longitude points from MKPolyline

I am trying to figure out a way to get all the latitude and longitude points from a MKPolyline drawn on a MKMapView on an iOS app. I know the MKPolyline does not store latitude and longitude points, but I am looking for a way to build an array of…
zumzum
  • 17,984
  • 26
  • 111
  • 172
29
votes
8 answers

How to detect taps on MKPolylines/Overlays like Maps.app?

When displaying directions on the built-in Maps.app on the iPhone you can "select" one of the usually 3 route alternatives that are displayed by tapping on it. I wan't to replicate this functionality and check if a tap lies within a given…
myell0w
  • 2,200
  • 2
  • 21
  • 25
20
votes
2 answers

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

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(_…
Andrew Robinson
  • 3,404
  • 3
  • 20
  • 26
15
votes
2 answers

Dotted line on map view

I can create a line between two points fairly easy with the below code (part of it anyways) How could I make the line dotted instead of solid? Also would it be possible to change the opacity the longer the line is? - (MKOverlayRenderer…
jdross
  • 1,188
  • 2
  • 11
  • 30
14
votes
7 answers

MKMapView - rendererForOverlay not called

I recently started learning objectiveC and started developing an app in iOS6. Now, I am trying to convert it for iOS7 and facing issues with MKMap. In iOS6, I was using viewForOverlay. In iOS7, I am changing it to renderForOverlay. But, my…
user2734323
  • 706
  • 1
  • 8
  • 19
13
votes
1 answer

Prevent MKPolygon to have knots

I'm developing an app with a map in which the user can draw a polygon area. My issue is what it's possible drawing polygons with knots (see the image) (I don't know if knot is the right word). I didn't find a simply way preventing the polygon to get…
Lisarien
  • 1,136
  • 1
  • 12
  • 24
13
votes
1 answer

Creating an MKMapSnapshotter with an MKPolylineRenderer

I thought iOS 7's MKMapSnapshotters 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…
PostCodeism
  • 1,070
  • 1
  • 12
  • 20
12
votes
1 answer

MKPolyline strange rendering related with zooming in MapKit

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…
Marcin Kapusta
  • 5,076
  • 3
  • 38
  • 55
11
votes
3 answers

Draw polyline using Swift

I'm trying to get an understanding of how to draw polylines using Swift. I've looked at the documentation, referenced some tutorials, and checked out some other SO posts, but I still can't get the thing to draw a line on my map. Here's my code. …
TJ Rogers
  • 500
  • 1
  • 6
  • 19
11
votes
1 answer

How to use MKPolylineView in Swift

I want to draw polyline in my Swift app. Swift code class MapViewController: UIViewController, MKMapViewDelegate { @IBOutlet var theMapView: MKMapView override func viewDidLoad() { super.viewDidLoad() setMapView() } …
SaeHyun Kim
  • 475
  • 2
  • 8
  • 26
11
votes
1 answer

Gradient along MKPolyLineView ( MKPolylineRenderer )

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…
Templar
  • 1,694
  • 1
  • 14
  • 32
10
votes
3 answers

Determining if Latitude/Longitude Point is in a MKPolygon within Mapview?

At this moment, I am trying to figure out whether a coordinate on a MKMapView is within a MKPolygon drawn out ahead of time with latitudes/longitudes. I am using CGPathContainsPoint to determine whether a coordinate is within the polygon on the map…
M_Jean
  • 101
  • 1
  • 4
9
votes
2 answers

Touch events on MKMapView's overlays

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…
Ben
  • 193
  • 2
  • 13
9
votes
1 answer

MKPolyline detect self-intersecting line OBJECTIVE C

How can I detect if an MKPolyline intersects itself? I tried researching this but only found problems that has two or more lines. How can I detect if I only have one line/one stroke? I want to detect it after the user releases the touch. I currently…
EdSniper
  • 271
  • 4
  • 21
9
votes
1 answer

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

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…
Greg
  • 34,042
  • 79
  • 253
  • 454
1
2 3
11 12