Annotations
-
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
See morecoordinate
property. The other methods of this protocol are optional.Declaration
Objective-C
@protocol MGLAnnotation <NSObject>
Swift
protocol MGLAnnotation : NSObjectProtocol
-
The MGLAnnotationImage class is responsible for presenting point-based annotations visually on a map view. Annotation image objects wrap
See moreUIImage
objects and may be recycled later and put into a reuse queue that is maintained by the map view.Declaration
Objective-C
@interface MGLAnnotationImage : NSObject
Swift
class MGLAnnotationImage
-
The
MGLAnnotationView
class is responsible for marking a point annotation with a view. Annotation views represent an annotation object, which is an object that corresponds to theMGLAnnotation
protocol. When an annotation’s geographic coordinate is visible in the map view, the map view asks its delegate to a corresponding annotation view. If an annotation view is created with a reuse identifier, the map view may recycle the view when it goes offscreen.Annotation views are compatible with UIKit, Core Animation, and other Cocoa Touch frameworks. On the other hand, if you do not need animation or interactivity such as dragging, you can use an
See moreMGLAnnotationImage
instead to conserve memory and optimize drawing performance.Declaration
Objective-C
@interface MGLAnnotationView : UIView
Swift
class MGLAnnotationView
-
A protocol for a
See moreUIView
subclass that displays information about a selected annotation near that annotation.Declaration
Objective-C
@protocol MGLCalloutView <NSObject>
Swift
protocol MGLCalloutView : NSObjectProtocol
-
The MGLCalloutViewDelegate protocol defines a set of optional methods that you can use to receive messages from an object that conforms to the MGLCalloutView protocol. The callout view uses these methods to inform the delegate that the user has interacted with the the callout view.
See moreDeclaration
Objective-C
@protocol MGLCalloutViewDelegate <NSObject>
Swift
protocol MGLCalloutViewDelegate : NSObjectProtocol
-
The
See moreMGLMultiPoint
class is an abstract superclass used to define shapes composed of multiple points. You should not create instances of this class directly. Instead, you should create instances of theMGLPolyline
orMGLPolygon
classes. However, you can use the method and properties of this class to access information about the specific points associated with the line or polygon.
-
The
MGLMultiPolygon
class represents a shape consisting of one or more polygons that do not overlap. For example, you would use anMGLMultiPolygon
object to represent an atoll together with an island in the atoll’s lagoon: the atoll itself would be oneMGLPolygon
object, while the inner island would be another.Note
MGLMultiPolygon
objects cannot be added to a map view using-[MGLMapView addAnnotations:]
and related methods.Declaration
Objective-C
@interface MGLMultiPolygon : MGLShape <MGLOverlay>
Swift
class MGLMultiPolygon : MGLShape, MGLOverlay
-
The
See moreMGLPolygon
class represents a shape consisting of one or more points that define a closed polygon. The points are connected end-to-end in the order they are provided. The first and last points are connected to each other to create the closed shape.Declaration
Objective-C
@interface MGLPolygon : MGLMultiPoint <MGLOverlay>
Swift
class MGLPolygon : MGLMultiPoint, MGLOverlay
-
The
MGLMultiPolyline
class represents a shape consisting of one or more polylines. For example, you could use anMGLMultiPolyline
object to represent both sides of a divided highway (dual carriageway), excluding the median (central reservation): each carriageway would be a distinctMGLPolyline
object.Note
MGLMultiPolyline
objects cannot be added to a map view using-[MGLMapView addAnnotations:]
and related methods.Declaration
Objective-C
@interface MGLMultiPolyline : MGLShape <MGLOverlay>
Swift
class MGLMultiPolyline : MGLShape, MGLOverlay
-
The
See moreMGLPolyline
class represents a shape consisting of one or more points that define connecting line segments. The points are connected end-to-end in the order they are provided. The first and last points are not connected to each other.Declaration
Objective-C
@interface MGLPolyline : MGLMultiPoint <MGLOverlay>
Swift
class MGLPolyline : MGLMultiPoint, MGLOverlay
-
The
See moreMGLPointAnnotation
class defines a concrete annotation object located at a specified point. You can use this class, rather than define your own, in situations where all you want to do is associate a point on the map with a title.Declaration
Objective-C
@interface MGLPointAnnotation : MGLShape
Swift
class MGLPointAnnotation : MGLShape
-
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. For example, overlays can take the form of common shapes such as rectangles and circles. They can also describe polygons and other complex shapes.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.
Because overlays are also annotations, they have similar usage pattern to annotations. When added to a map view using the
See more-addOverlay:
method, that view detects whenever the overlay’s defined region intersects the visible portion of the map. At that point, the map view asks its delegate to provide a special overlay view to draw the visual representation of the overlay. If you add an overlay to a map view as an annotation instead, it is treated as an annotation with a single point.Declaration
Objective-C
@protocol MGLOverlay <MGLAnnotation>
Swift
protocol MGLOverlay : MGLAnnotation
-
The
See moreMGLShape
class is an abstract class that defines the basic properties for all shape-based annotation objects. This class must be subclassed and cannot be used as is. Subclasses are responsible for defining the geometry of the shape and providing an appropriate value for the coordinate property inherited from theMGLAnnotation
protocol.Declaration
Objective-C
@interface MGLShape : NSObject <MGLAnnotation>
Swift
class MGLShape : NSObject, MGLAnnotation
-
The
MGLShapeCollection
class represents a shape consisting of one or more distinct but related shapes that are instances ofMGLShape
. The constituent shapes can be a mixture of different kinds of shapes.Note
MGLShapeCollection
objects cannot be added to a map view using-[MGLMapView addAnnotations:]
and related methods.Declaration
Objective-C
@interface MGLShapeCollection : MGLShape
Swift
class MGLShapeCollection : MGLShape
-
The MGLUserLocation class defines a specific type of annotation that identifies the user’s current location. You do not create instances of this class directly. Instead, you retrieve an existing MGLUserLocation object from the userLocation property of the map view displayed in your application.
See moreDeclaration
Objective-C
@interface MGLUserLocation : NSObject <MGLAnnotation>
Swift
class MGLUserLocation : NSObject