1

Im trying to create a shape on my map but I'm having a hard time finding any information about mkpolygon with swift. I was hoping someone on here would see this and point me into the right direction.

This is what I currently have but the polygon is not appearing.

func mapView(mapView: MKMapView, rendererForOverlay overlay: MKOverlay) -> MKOverlayRenderer {
    let pr = MKPolygonRenderer(overlay: overlay)
    pr.strokeColor = UIColor.purpleColor()
    pr.lineWidth = 14
    return pr
}

func createPolyline(mapView: MKMapView) {
    var points=[CLLocationCoordinate2DMake(49.142677, -123.135139),CLLocationCoordinate2DMake(49.142730, -123.125794),CLLocationCoordinate2DMake(49.140874, -123.125805),CLLocationCoordinate2DMake(49.140885, -123.135214)]
    let polygon = MKPolygon(coordinates: &points, count: points.count)
    self.mapView.addOverlay(polygon)

}
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Thomas rocks
  • 111
  • 1
  • 1
  • 13

1 Answers1

1

Turns out what I was forgetting was to set the map view delegate. I will leave this up incase anyone wants to see what I used to get mkpolygon working in swift.

Thomas rocks
  • 111
  • 1
  • 1
  • 13