MGLLineStyleAnnotation
@interface MGLLineStyleAnnotation : MGLStyleAnnotation
An MGLLineStyleAnnotation is a type of style layer annotation that
renders one or more stroked polylines on the map.
To display a line style annotation on a map, use one of the initializers below to create a line
style annotation object. Then, use -[MGLLineAnnotationController add:] to add the annotation
to a line style annotation controller.
Example
func mapView(_ mapView: MGLMapView, didFinishLoading style: MGLStyle) {
let lineAnnotationController = MGLLineAnnotationController(mapView: self.mapView)
let lineCoordinates = [
CLLocationCoordinate2D(latitude: 59, longitude: 18),
CLLocationCoordinate2D(latitude: 60, longitude: 20)
]
let line = MGLLineStyleAnnotation(coordinates: lineCoordinates, count: UInt(lineCoordinates.count))
line.color = .purple
lineAnnotationController.add(line)
}
-
Returns a line style annotation initialized with coordinates.
Declaration
Objective-C
- (nonnull instancetype)initWithCoordinates:(id)coordinates count:(NSUInteger)count;Swift
init(coordinates: Any!, count: UInt)Parameters
coordinatesAn array of coordinates representing the line shape.
Return Value
An initialized line style annotation.
-
Returns a line style annotation initialized with coordinates and a specified line color.
Declaration
Objective-C
- (nonnull instancetype)initWithCoordinates:(id)coordinates count:(NSUInteger)count color:(nonnull UIColor *)color;Swift
init(coordinates: Any!, count: UInt, color: UIColor)Parameters
coordinatesAn array of coordinates representing the line shape.
colorThe line color of the line style annotation.
Return Value
An initialized line style annotation with a defined line color.
-
The color with which the line style annotation will be drawn. Defaults to black.
This property corresponds to the
line-colorproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (readwrite, strong, nonatomic) UIColor *_Nonnull lineColor;Swift
var lineColor: UIColor { get set } -
The width of the line style annotation, measured in screen points. Defaults to
1.This property corresponds to the
line-widthproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) CGFloat lineWidth;Swift
var lineWidth: CGFloat { get set } -
The opacity of the line style annotation, represented as a range of values between
0and1. Defaults to1.This property corresponds to the
line-opacityproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) CGFloat lineOpacity;Swift
var lineOpacity: CGFloat { get set } -
Draws a line casing outside of the line style annotation’s actual coordinate path. Value indicates the width of the inner gap, measured in screen points. Defaults to
0.This property corresponds to the
line-gap-widthproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) CGFloat lineGapWidth;Swift
var lineGapWidth: CGFloat { get set } -
The display of the line style annotation when joining with other lines, as specified by
MGLLineJoin. Defaults tomiter.This property corresponds to the
line-joinproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) int lineJoin;Swift
var lineJoin: CGLineJoin { get set } -
The blur applied to the line, measured in screen points greater than or equal to zero. Defaults to
0.This property corresponds to the
line-blurproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) CGFloat lineBlur;Swift
var lineBlur: CGFloat { get set } -
The line style annotation’s offset. A positive value offsets the line to the right, relative to the direction of the line. A negative value offsets the line to the left. Defaults to
0.This property corresponds to the
line-offsetproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) CGFloat lineOffset;Swift
var lineOffset: CGFloat { get set } -
The name of the image within an
MGLMapStyle‘s sprite to use for drawing image lines. Not set by default.To add an image to the map style’s sprite, use the
-[MGLStyle setImage:forName:]method within the Mapbox Maps SDK for iOS. For seamless patterns, image width must be a factor of two (2, 4, 8, …, 512).This property corresponds to the
line-patternproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (readwrite, strong, nonatomic) NSString *_Nonnull linePattern;Swift
var linePattern: String { get set }
MGLLineStyleAnnotation Class Reference