MGLCalloutView
@protocol MGLCalloutView <NSObject>
A protocol for a UIView
subclass that displays information about a selected annotation near that annotation.
To receive updates from an object that conforms to the MGLCalloutView
protocol, use the optional methods available in the MGLCalloutViewDelegate
protocol.
representedObject
An object conforming to the MGLAnnotation
protocol whose details this callout view displays.
Declaration
Objective-C
@property (nonatomic, strong, readwrite)
id<MGLAnnotation> _Nonnull representedObject;
leftAccessoryView
A view that the user may tap to perform an action. This view is conventionally positioned on the left side of the callout view.
Declaration
Objective-C
@property (nonatomic, strong, readwrite) UIView *_Nonnull leftAccessoryView;
Swift
var leftAccessoryView: UnsafeMutablePointer<Int32> { get set }
rightAccessoryView
A view that the user may tap to perform an action. This view is conventionally positioned on the right side of the callout view.
Declaration
Objective-C
@property (nonatomic, strong, readwrite) UIView *_Nonnull rightAccessoryView;
Swift
var rightAccessoryView: UnsafeMutablePointer<Int32> { get set }
delegate
An object conforming to the MGLCalloutViewDelegate
method that receives messages related to the callout view’s interactive subviews.
Declaration
Objective-C
@property (nonatomic, weak, readwrite)
id<MGLCalloutViewDelegate> _Nullable delegate;
Swift
weak var delegate: MGLCalloutViewDelegate? { get set }
-presentCalloutFromRect:inView:constrainedToView:animated:
Unavailable
Use -presentCalloutFromRect:inView:constrainedToRect:animated:
instead.
Presents a callout view by adding it to view
and pointing at the given rect of view
’s bounds. Constrains the callout to the bounds of the given view.
Declaration
Objective-C
- (void)presentCalloutFromRect:(CGRect)rect
inView:(nonnull UIView *)view
constrainedToView:(nonnull UIView *)constrainedView
animated:(BOOL)animated;
-presentCalloutFromRect:inView:constrainedToRect:animated:
Presents a callout view by adding it to view
and pointing at the given rect of view
’s bounds. Constrains the callout to the rect in the space of view
.
Declaration
Objective-C
- (void)presentCalloutFromRect:(CGRect)rect
inView:(nonnull UIView *)view
constrainedToRect:(CGRect)constrainedRect
animated:(BOOL)animated;
Swift
func presentCallout(fromRect rect: Any!, inView view: Any!, constrainedToRect constrainedRect: Any!, animated: Bool)
-dismissCalloutAnimated:
Dismisses the callout view.
Declaration
Objective-C
- (void)dismissCalloutAnimated:(BOOL)animated;
Swift
func dismissCallout(animated: Bool)
-marginInsetsHintForPresentationFromRect:
If implemented, should provide margins to expand the rect the callout is presented from.
These are used to determine positioning. Currently only the top and bottom properties of the return value are used. For example, { .top = -50.0, .left = -10.0, .bottom = 0.0, .right = -10.0 }
indicates a 50 point margin above the presentation origin rect (and 10 point margins to the left and the right) in which the callout is assumed to be displayed.
There are no assumed defaults for these margins, as they should be calculated from the callout that is to be presented. For example, SMCalloutView
generates the top margin from the callout height, but the left and right margins from a minimum width that the callout should have.
Declaration
Objective-C
- (UIEdgeInsets)marginInsetsHintForPresentationFromRect:(CGRect)rect;
Swift
optional func marginInsetsHintForPresentation(from rect: Any!) -> Any!
Parameters
rect
Rect that the callout is presented from. This should be the same as the one passed in -[MGLCalloutView presentCalloutFromRect:inView:constrainedToRect:animated:]
Return Value
UIEdgeInsets
representing the margins. Values should be negative.
anchoredToAnnotation
A Boolean value indicating whether the callout view should be anchored to the corresponding annotation. You can adjust the callout view’s precise location by overriding -[UIView setCenter:]. The callout view will not be anchored to the annotation if this optional property is unimplemented.
Declaration
Objective-C
@optional
@property (nonatomic, assign, unsafe_unretained, readonly,
getter=isAnchoredToAnnotation) BOOL anchoredToAnnotation;
Swift
optional var isAnchoredToAnnotation: Bool { get }
dismissesAutomatically
A Boolean value indicating whether the callout view should be dismissed automatically when the map view’s viewport changes. Note that a single tap on the map view still dismisses the callout view regardless of the value of this property. The callout view will be dismissed if this optional property is unimplemented.
Declaration
Objective-C
@optional
@property (nonatomic, assign, unsafe_unretained, readonly)
BOOL dismissesAutomatically;
Swift
optional var dismissesAutomatically: Bool { get }
iOS SDK
Examples
SDK JS Reference
- Annotations
- Appendices
- NSExpression(MGLAdditions)
- NSValue(MGLAdditions)
- NSValue(MGLCircleStyleLayerAdditions)
- NSValue(MGLFillExtrusionStyleLayerAdditions)
- NSValue(MGLFillStyleLayerAdditions)
- NSValue(MGLHillshadeStyleLayerAdditions)
- NSValue(MGLLineStyleLayerAdditions)
- NSValue(MGLRasterStyleLayerAdditions)
- NSValue(MGLSymbolStyleLayerAdditions)
- MGLAccountManager
- MGLAnnotationImage
- MGLAnnotationView
- MGLAttributedExpression
- MGLAttributionInfo
- MGLBackgroundStyleLayer
- MGLCircleStyleLayer
- MGLClockDirectionFormatter
- MGLCompassButton
- MGLCompassDirectionFormatter
- MGLComputedShapeSource
- MGLCoordinateFormatter
- MGLDistanceFormatter
- MGLFillExtrusionStyleLayer
- MGLFillStyleLayer
- MGLForegroundStyleLayer
- MGLHeatmapStyleLayer
- MGLHillshadeStyleLayer
- MGLImageSource
- MGLLight
- MGLLineStyleLayer
- MGLLoggingConfiguration
- MGLMapCamera
- MGLMapSnapshot
- MGLMapSnapshotOptions
- MGLMapSnapshotOverlay
- MGLMapSnapshotter
- MGLMapView
- MGLMultiPoint
- MGLMultiPolygon
- MGLMultiPolyline
- MGLNetworkConfiguration
- MGLOfflinePack
- MGLOfflineStorage
- MGLPointAnnotation
- MGLPointCollection
- MGLPolygon
- MGLPolyline
- MGLRasterStyleLayer
- MGLRasterTileSource
- MGLShape
- MGLShapeCollection
- MGLShapeOfflineRegion
- MGLShapeSource
- MGLSource
- MGLStyle
- MGLStyleLayer
- MGLSymbolStyleLayer
- MGLTilePyramidOfflineRegion
- MGLTileSource
- MGLUserLocation
- MGLUserLocationAnnotationView
- MGLUserLocationAnnotationViewStyle
- MGLVectorStyleLayer
- MGLVectorTileSource
- MGLAnnotationVerticalAlignment
- MGLAnnotationViewDragState
- MGLAttributionInfoStyle
- MGLCirclePitchAlignment
- MGLCircleScaleAlignment
- MGLCircleTranslationAnchor
- MGLDEMEncoding
- MGLErrorCode
- MGLFillExtrusionTranslationAnchor
- MGLFillTranslationAnchor
- MGLHillshadeIlluminationAnchor
- MGLIconAnchor
- MGLIconPitchAlignment
- MGLIconRotationAlignment
- MGLIconTextFit
- MGLIconTranslationAnchor
- MGLLightAnchor
- MGLLineCap
- MGLLineJoin
- MGLLineTranslationAnchor
- MGLLoggingLevel
- MGLMapDebugMaskOptions
- MGLOfflinePackState
- MGLOrnamentPosition
- MGLOrnamentVisibility
- MGLRasterResamplingMode
- MGLResourceKind
- MGLSymbolPlacement
- MGLSymbolZOrder
- MGLTextAnchor
- MGLTextJustification
- MGLTextPitchAlignment
- MGLTextRotationAlignment
- MGLTextTransform
- MGLTextTranslationAnchor
- MGLTextWritingMode
- MGLTileCoordinateSystem
- MGLUserTrackingMode
- Formatters
- Geometry
- Location Updates
- Maps
- Offline Maps
- Other Categories
- Other Classes
- Other Constants
- Other Enumerations
- Other Functions
- Other Protocols
- Other Structures
- Other Type Definitions
- Primitive Shapes
- MGLAnnotation
- MGLCalloutView
- MGLCalloutViewDelegate
- MGLCluster
- MGLComputedShapeSourceDataSource
- MGLFeature
- MGLLocationManager
- MGLLocationManagerDelegate
- MGLMapSnapshotterDelegate
- MGLMapViewDelegate
- MGLOfflineRegion
- MGLOfflineStorageDelegate
- MGLOverlay
- MGLStylable
- MGLCoordinateBounds
- MGLCoordinateQuad
- MGLCoordinateSpan
- MGLOfflinePackProgress
- MGLSphericalPosition
- MGLTransition
- Style Content
- Style Layers
- Style Primitives
- Styling the Map
- MGLCoordinateBounds
- MGLCoordinateQuad
- MGLCoordinateSpan
- MGLOfflinePackProgress
- MGLSphericalPosition
- MGLTransition
- User Interaction
- Customizing Fonts
- Information for Style Authors
- Gesture Recognizers
- Info.plist Keys
- Migrating to Expressions
- Predicates and expressions
- Tile URL Templates
- Working with GeoJSON Data