MLNPolygon class

An MLNPolygon object represents a closed shape consisting of four or more vertices, specified as CLLocationCoordinate2D instances, and the edges that connect them. For example, you could use a polygon shape to represent a building, a lake, or an area you want to highlight.

You can add polygon shapes to the map by adding them to an MLNShapeSource object. Configure the appearance of an MLNShapeSource’s or MLNVectorTileSource’s polygons collectively using an MLNVectorTileSource or MLNSymbolStyleLayer object. To access a polygon’s attributes, use an MLNPolygonFeature object.

Alternatively, you can add a polygon overlay directly to a map view using the MLNMapView/addAnnotation: or MLNMapView/addOverlay: method. Configure a polygon overlay’s appearance using MLNMapViewDelegate/mapView:strokeColorForShapeAnnotation: and MLNMapViewDelegate/mapView:fillColorForPolygonAnnotation:.

The vertices are automatically connected in the order in which you provide them. You should close the polygon by specifying the same CLLocationCoordinate2D as the first and last vertices; otherwise, the polygon’s fill may not cover the area you expect it to. To avoid filling the space within the shape, give the polygon a transparent fill or use an MLNPolyline object.

A polygon may have one or more interior polygons, or holes, that you specify as MLNPolygon objects with the +polygonWithCoordinates:count:interiorPolygons: method. For example, if a polygon represents a lake, it could exclude an island within the lake using an interior polygon. Interior polygons may not themselves have interior polygons. To represent a shape that includes a polygon within a hole or, more generally, to group multiple polygons together in one shape, use an MLNMultiPolygon or MLNMultiPolygon object.

To make the polygon straddle the antimeridian, specify some longitudes less than −180 degrees or greater than 180 degrees.

TODO: Add a polygon annotation, learn how to initialize an MLNPolygon object from an array of coordinates.

Inheritance
Implemented types
Implementers

Constructors

MLNPolygon()
Returns a new instance of MLNPolygon constructed with the default new method.
factory
MLNPolygon.castFrom(ObjCObjectBase other)
Constructs a MLNPolygon that points to the same underlying object as other.
MLNPolygon.castFromPointer(Pointer<ObjCObject> other, {bool retain = false, bool release = false})
Constructs a MLNPolygon that wraps the given raw object pointer.

Properties

coordinate CLLocationCoordinate2D
The center point (specified as a map coordinate) of the annotation. (required) (read-only)
no setteroverride
coordinates Pointer<CLLocationCoordinate2D>
The array of vertices associated with the shape.
no setterinherited
debugDescription$1 → NSString
debugDescription
no setterinherited
description$1 → NSString
description
no setterinherited
hash$1 int
hash
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
interiorPolygons → NSArray?
The array of polygons nested inside the receiver.
no setter
isProxy bool
isProxy
no setterinherited
overlayBounds MLNCoordinateBounds
The cooordinate rectangle that encompasses the overlay. (required) (read-only)
no setter
pointCount int
The number of vertices in the shape.
no setterinherited
ref → ObjCObjectRef
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
subtitle ↔ NSString?
The string containing the annotation’s subtitle.
getter/setter pairinherited-setteroverride-getter
superclass$1 → ObjCObjectBase
superclass
no setterinherited
title ↔ NSString?
The string containing the annotation’s title.
getter/setter pairinherited-setteroverride-getter

Methods

appendCoordinates(Pointer<CLLocationCoordinate2D> coords, {required int count}) → void
Appends the given vertices to the shape.
inherited
autorelease() MLNPolygon
autorelease
override
class$1() → ObjCObjectBase
class
inherited
conformsToProtocol$1(Protocol aProtocol) bool
conformsToProtocol:
inherited
copy() → ObjCObjectBase
copy
inherited
dealloc() → void
dealloc
inherited
doesNotRecognizeSelector(Pointer<ObjCSelector> aSelector) → void
doesNotRecognizeSelector:
inherited
encodeWithCoder(NSCoder coder) → void
encodeWithCoder:
inherited
forwardingTargetForSelector(Pointer<ObjCSelector> aSelector) → ObjCObjectBase
forwardingTargetForSelector:
inherited
forwardInvocation(NSInvocation anInvocation) → void
forwardInvocation:
inherited
geoJSONDataUsingEncoding(int encoding) → NSData
Returns the GeoJSON string representation of the shape encapsulated in a data object.
inherited
getCoordinates(Pointer<CLLocationCoordinate2D> coords, {required NSRange range}) → void
Retrieves the vertices of part of the shape.
inherited
init() MLNPolygon
init
override
initWithCoder(NSCoder coder) MLNPolygon?
initWithCoder:
override
insertCoordinates(Pointer<CLLocationCoordinate2D> coords, {required int count, required int atIndex}) → void
Inserts the given vertices into the shape.
inherited
intersectsOverlayBounds(MLNCoordinateBounds overlayBounds$1) bool
Returns a Boolean indicating whether the specified rectangle intersects the receiver’s shape.
isEqual(ObjCObjectBase object) bool
isEqual:
inherited
isKindOfClass(ObjCObjectBase aClass) bool
isKindOfClass:
inherited
isMemberOfClass(ObjCObjectBase aClass) bool
isMemberOfClass:
inherited
methodForSelector(Pointer<ObjCSelector> aSelector) Pointer<NativeFunction<Void Function()>>
methodForSelector:
inherited
methodSignatureForSelector(Pointer<ObjCSelector> aSelector) → NSMethodSignature
methodSignatureForSelector:
inherited
mutableCopy() → ObjCObjectBase
mutableCopy
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
performSelector(Pointer<ObjCSelector> aSelector) → ObjCObjectBase
performSelector:
inherited
performSelector$1(Pointer<ObjCSelector> aSelector, {required ObjCObjectBase withObject}) → ObjCObjectBase
performSelector:withObject:
inherited
performSelector$2(Pointer<ObjCSelector> aSelector, {required ObjCObjectBase withObject, required ObjCObjectBase withObject$1}) → ObjCObjectBase
performSelector:withObject:withObject:
inherited
release() → void
release
inherited
removeCoordinatesInRange(NSRange range) → void
Removes the vertices at the given range from the shape.
inherited
replaceCoordinatesInRange(NSRange range, {required Pointer<CLLocationCoordinate2D> withCoordinates}) → void
Replaces the vertices at the given range in the shape with the same number of vertices from a given C array.
inherited
replaceCoordinatesInRange$1(NSRange range, {required Pointer<CLLocationCoordinate2D> withCoordinates, required int count}) → void
Replaces the vertices at the given range in the shape with the specified number of vertices from a given C array.
inherited
respondsToSelector(Pointer<ObjCSelector> aSelector) bool
respondsToSelector:
inherited
retain() MLNPolygon
retain
override
retainCount() int
retainCount
inherited
self$1() MLNPolygon
self
override
setCoordinates(Pointer<CLLocationCoordinate2D> coords, {required int count}) → void
Sets the shape’s vertices to the given C array of vertices.
inherited
toString() String
A string representation of this object.
inherited
zone() Pointer<NSZone>
zone
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

alloc() MLNPolygon
alloc
override
allocWithZone(Pointer<NSZone> zone) MLNPolygon
allocWithZone:
override
getSupportsSecureCoding() bool
supportsSecureCoding
override
isInstance(ObjCObjectBase obj) bool
Returns whether obj is an instance of MLNPolygon.
override
new$() MLNPolygon
new
override
polygonWithCoordinates(Pointer<CLLocationCoordinate2D> coords, {required int count}) MLNPolygon
Creates and returns an MLNPolygon object from the specified set of coordinates.
polygonWithCoordinates$1(Pointer<CLLocationCoordinate2D> coords, {required int count, NSArray? interiorPolygons$1}) MLNPolygon
Creates and returns an MLNPolygon object from the specified set of coordinates and interior polygons.
shapeWithData(NSData data, {required int encoding, required Pointer<Pointer<ObjCObject>> error}) MLNShape?
Returns an MLNShape object initialized with the given data interpreted as a string containing a GeoJSON object.
override