• The MGLAnnotation protocol is used to provide annotation-related information to a map view. To use this protocol, you adopt it in any custom objects that store or represent annotation data. Each object then serves as the source of information about a single map annotation and provides critical information, such as the annotation’s location on the map. Annotation objects do not provide the visual representation of the annotation but typically coordinate (in conjunction with the map view’s delegate) the creation of an appropriate objects to handle the display.

    An object that adopts this protocol must implement the coordinate property. The other methods of this protocol are optional.

    See the Annotation models and Annotation views examples to learn how to add objects that follow the MGLAnnotation protocol.

    See more

    Declaration

    Objective-C

    @protocol MGLAnnotation <NSObject>

    Swift

    protocol MGLAnnotation : NSObjectProtocol
  • The MGLOverlay protocol defines a specific type of annotation that represents both a point and an area on a map. Overlay objects are essentially data objects that contain the geographic data needed to represent the map area. Overlays can take the form of a polyline or polygon.

    You use overlays to layer more sophisticated content on top of a map view. For example, you could use an overlay to show the boundaries of a national park or trace a bus route along city streets. This SDK defines several concrete classes that conform to this protocol and define standard shapes.

    See more

    Declaration

    Objective-C

    @protocol MGLOverlay <MGLAnnotation>

    Swift

    protocol MGLOverlay : MGLAnnotation
  • MGLShape is an abstract class that represents a shape or annotation. Shapes constitute the content of a map — not only the overlays atop the map, but also the content that forms the base map.

    Create instances of MGLPointAnnotation, MGLPointCollection, MGLPolyline, MGLMultiPolyline, MGLPolygon, MGLMultiPolygon, or MGLShapeCollection in order to use MGLShape‘s methods. Do not create instances of MGLShape directly, and do not create your own subclasses of this class. The shape classes correspond to the Geometry object types in the GeoJSON standard, but some have nonstandard names for backwards compatibility.

    Although you do not create instances of this class directly, you can use its +[MGLShape shapeWithData:encoding:error:] factory method to create one of the concrete subclasses of MGLShape noted above from GeoJSON data. To access a shape’s attributes, use the corresponding MGLFeature class instead.

    You can add shapes to the map by adding them to an MGLShapeSource object. Configure the appearance of an MGLShapeSource’s or MGLVectorTileSource’s shapes collectively using a concrete instance of MGLVectorStyleLayer. Alternatively, you can add some kinds of shapes directly to a map view as annotations or overlays.

    You can filter the features in a MGLVectorStyleLayer or vary their layout or paint attributes based on the features’ geographies. Pass an MGLShape into an NSPredicate with the format SELF IN %@ or %@ CONTAINS SELF and set the MGLVectorStyleLayer.predicate property to that predicate, or set a layout or paint attribute to a similarly formatted NSExpression.

    See more

    Declaration

    Objective-C

    
    @interface MGLShape : NSObject <MGLAnnotation, NSSecureCoding>

    Swift

    class MGLShape : NSObject, MGLAnnotation, NSSecureCoding
  • The MGLMultiPoint class is an abstract superclass used to define shapes composed of multiple vertices.

    Create instances of MGLPolyline or MGLPolygon in order to use properties of MGLMultiPoint. Do not create instances of MGLMultiPoint directly and do not create your own subclasses of this class. You can use the method and properties of this class to access information about the vertices of the line or polygon.

    Do not confuse MGLMultiPoint with MGLPointCollection, which represents a collection of related but disconnected points.

    See more

    Declaration

    Objective-C

    
    @interface MGLMultiPoint : MGLShape

    Swift

    class MGLMultiPoint : MGLShape