MQMapViewTrafficDelegate
@protocol MQMapViewTrafficDelegate <NSObject>
The MQMapViewTrafficDelegate
protocol defines a set of optional methods that you
can use to receive traffic-related update messages. Because many map operations
require the MQMapView
class to load data asynchronously, the map view calls
these methods to notify your application when specific operations complete. The
map view also uses these methods to request information about traffic annotations
displayed on the map, such as the styles and interaction modes to apply to
individual annotations.
-
Implement this method to mark a traffic annotation with a static image. If you want to mark a particular traffic annotation with an annotation view instead, omit this method or have it return nil for that annotation, then implement -mapView:viewForTrafficAnnotation:.
Static annotation images use less memory and draw more quickly than annotation views. On the other hand, annotation views are compatible with UIKit, Core Animation, and other Cocoa Touch frameworks.
Declaration
Objective-C
- (id)mapView:(id)mapView imageForTrafficAnnotation:(nonnull id)annotation;
Swift
optional func mapView(_ mapView: Any!, imageForTrafficAnnotation annotation: Any) -> Any!
Parameters
mapView
The map view that requested the annotation image.
annotation
The object representing the annotation that is about to be displayed.
Return Value
The annotation image object to display for the given annotation or nil if you want to display the default image or an annotation view.
-
Implement this method to mark a traffic annotation with a view object. If you want to mark a particular traffic annotation with a static image instead, omit this method or have it return nil for that annotation, then implement -mapView:imageForAnnotation: instead.
Annotation views are compatible with UIKit, Core Animation, and other Cocoa Touch frameworks. On the other hand, static annotation images use less memory and draw more quickly than annotation views.
Declaration
Objective-C
- (id)mapView:(id)mapView viewForTrafficAnnotation:(nonnull id)annotation;
Swift
optional func mapView(_ mapView: Any!, viewForTrafficAnnotation annotation: Any) -> Any!
Parameters
mapView
The map view that requested the annotation view.
annotation
The object representing the annotation that is about to be displayed.
Return Value
The view object to display for the given annotation or nil if you want to display an annotation image instead.
-
Returns the line width in points to use when rendering the outline of a traffic polyline annotation. By default, the polyline is outlined with a line 4.0 points wide.
Declaration
Objective-C
- (CGFloat)mapView:(id)mapView lineWidthForTrafficPolylineAnnotation:(id)annotation;
Swift
optional func mapView(_ mapView: Any!, lineWidthForTrafficPolylineAnnotation annotation: Any!) -> Any!
Parameters
mapView
mapView descriptionThe map view rendering the traffic annotation.
annotation
The annotation being rendered.
Return Value
A line width for the traffic polyline, measured in points.
-
Returns the color to use when rendering the outline of a shape annotation.
Opacity may be set by specifying an alpha component. The default alpha value is 1.0 and results in a completely opaque stroke.
Declaration
Objective-C
- (nullable UIColor *)mapView:(id)mapView strokeColorForTrafficShapeAnnotation:(id)annotation;
Swift
optional func mapView(_ mapView: Any!, strokeColorForTrafficShapeAnnotation annotation: Any!) -> Any!
Parameters
mapView
The map view rendering the traffic annotation.
annotation
The annotation being rendered.
Return Value
A color to use for the traffic annotation.