Mac Developer Library

Developer

MapKit Framework Reference MKPolygon Class Reference

Options
Deployment Target:

On This Page
Language:

MKPolygon

The MKPolygon class represents a shape consisting of one or more points that define a closed polygon. The points are connected end-to-end in the order they are provided. The first and last points are connected to each other to create the closed shape.

When creating a polygon, you can mask out portions of the polygon by specifying one or more interior polygons. For the polygons you specify, this class uses the even-odd fill rule to determine the final occupied area. When applied to overlapping polygons, this rule can cause specific regions to be masked out (and thereby removed) from the total occupied area. For more information about how fill rules are applied to paths, see Paths in Quartz 2D Programming Guide.

Inheritance


Import Statement


Swift

import MapKit

Objective-C

@import MapKit;

Availability


Available in OS X v10.9 and later.
  • Creates and returns an MKPolygon object from the specified set of map points.

    Declaration

    Swift

    convenience init!(points points: UnsafeMutablePointer<MKMapPoint>, count count: Int)

    Objective-C

    + (instancetype)polygonWithPoints:(MKMapPoint *)points count:(NSUInteger)count

    Parameters

    points

    The array of map points defining the shape. The data in this array is copied to the new object.

    count

    The number of items in the points array.

    Return Value

    A new polygon object.

    Import Statement

    Objective-C

    @import MapKit;

    Swift

    import MapKit

    Availability

    Available in OS X v10.9 and later.

  • Creates and returns an MKPolygon object from the specified set of map points and interior polygons.

    Declaration

    Swift

    convenience init!(points points: UnsafeMutablePointer<MKMapPoint>, count count: Int, interiorPolygons interiorPolygons: [AnyObject]!)

    Objective-C

    + (instancetype)polygonWithPoints:(MKMapPoint *)points count:(NSUInteger)count interiorPolygons:(NSArray *)interiorPolygons

    Parameters

    points

    The array of map points defining the shape. The data in this array is copied to the new object.

    count

    The number of items in the points array.

    interiorPolygons

    An array of MKPolygon objects that define one or more cutout regions for the receiver’s polygon.

    Return Value

    A new polygon object.

    Import Statement

    Objective-C

    @import MapKit;

    Swift

    import MapKit

    Availability

    Available in OS X v10.9 and later.

  • Creates and returns an MKPolygon object from the specified set of coordinates.

    Declaration

    Swift

    convenience init!(coordinates coords: UnsafeMutablePointer<CLLocationCoordinate2D>, count count: Int)

    Objective-C

    + (instancetype)polygonWithCoordinates:(CLLocationCoordinate2D *)coords count:(NSUInteger)count

    Parameters

    coords

    The array of coordinates defining the shape. The data in this array is copied to the new object.

    count

    The number of items in the coords array.

    Return Value

    A new polygon object.

    Import Statement

    Objective-C

    @import MapKit;

    Swift

    import MapKit

    Availability

    Available in OS X v10.9 and later.

  • Creates and returns an MKPolygon object from the specified set of coordinates and interior polygons.

    Declaration

    Swift

    convenience init!(coordinates coords: UnsafeMutablePointer<CLLocationCoordinate2D>, count count: Int, interiorPolygons interiorPolygons: [AnyObject]!)

    Objective-C

    + (instancetype)polygonWithCoordinates:(CLLocationCoordinate2D *)coords count:(NSUInteger)count interiorPolygons:(NSArray *)interiorPolygons

    Parameters

    coords

    The array of coordinates defining the shape. The data in this array is copied to the new object.

    count

    The number of items in the coords array.

    interiorPolygons

    An array of MKPolygon objects that define one or more cutout regions for the receiver’s polygon.

    Return Value

    A new polygon object.

    Import Statement

    Objective-C

    @import MapKit;

    Swift

    import MapKit

    Availability

    Available in OS X v10.9 and later.

  • The array of polygons nested inside the receiver. (read-only)

    Declaration

    Swift

    var interiorPolygons: [AnyObject]! { get }

    Objective-C

    @property(readonly) NSArray *interiorPolygons

    Discussion

    When a polygon is rendered on screen, the area occupied by any interior polygons is masked out and not considered part of the polygon.

    Import Statement

    Objective-C

    @import MapKit;

    Swift

    import MapKit

    Availability

    Available in OS X v10.9 and later.