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

    coordinates

    An 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

    coordinates

    An array of coordinates representing the line shape.

    color

    The 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-color property 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-width property 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 0 and 1. Defaults to 1.

    This property corresponds to the line-opacity property 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-width property 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 to miter.

    This property corresponds to the line-join property 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-blur property 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-offset property 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-pattern property in the style Mapbox Style Specification.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic) NSString *_Nonnull linePattern;

    Swift

    var linePattern: String { get set }