MLNPolyline class

An MLNPolyline object represents a shape consisting of two or more vertices, specified as CLLocationCoordinate2D instances, and the line segments that connect them. For example, you could use an polyline to represent a road or the path along which something moves.

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

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

The vertices are automatically connected in the order in which you provide them. The first and last vertices are not connected to each other, but you can specify the same CLLocationCoordinate2D as the first and last vertices in order to close the polyline. To fill the space within the shape, use an MLNPolygon object. To group multiple polylines together in one shape, use an MLNMultiPolyline or MLNShapeCollection object.

To make the polyline go across the antimeridian or international date line, specify some longitudes less than −180 degrees or greater than 180 degrees. For example, a polyline that stretches from Tokyo to San Francisco would have coordinates of (35.68476, -220.24257) and (37.78428, -122.41310).

let coordinates = [
CLLocationCoordinate2D(latitude: 35.68476, longitude: -220.24257),
CLLocationCoordinate2D(latitude: 37.78428, longitude: -122.41310)
]
let polyline = MLNPolyline(coordinates: coordinates, count: UInt(coordinates.count))

A polyline is known as a LineString geometry in GeoJSON.

Inheritance
Implemented types
Implementers

Constructors

MLNPolyline()
Returns a new instance of MLNPolyline constructed with the default new method.
factory
MLNPolyline.castFrom(ObjCObjectBase other)
Constructs a MLNPolyline that points to the same underlying object as other.
MLNPolyline.castFromPointer(Pointer<ObjCObject> other, {bool retain = false, bool release = false})
Constructs a MLNPolyline 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
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() MLNPolyline
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() MLNPolyline
init
override
initWithCoder(NSCoder coder) MLNPolyline?
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() MLNPolyline
retain
override
retainCount() int
retainCount
inherited
self$1() MLNPolyline
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() MLNPolyline
alloc
override
allocWithZone(Pointer<NSZone> zone) MLNPolyline
allocWithZone:
override
getSupportsSecureCoding() bool
supportsSecureCoding
override
isInstance(ObjCObjectBase obj) bool
Returns whether obj is an instance of MLNPolyline.
override
new$() MLNPolyline
new
override
polylineWithCoordinates(Pointer<CLLocationCoordinate2D> coords, {required int count}) MLNPolyline
Creates and returns an MLNPolyline object from the specified set of coordinates.
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