AWFMapStrategy
Objective-C
@protocol AWFMapStrategy <NSObject>
Swift
protocol AWFMapStrategy : NSObjectProtocol
An AWFMapStrategy
object provides a common interface between a specific map SDK and the application. This object
is responsible for determining how to add and remove overlay and annotation objects on the map, as well as providing other
basic information about the state of its internal map view, such as bounding coordinates, zoom level, etc.
The base implementation of this class doesn’t do anything and should be subclassed for each supported map SDK. Subclasses should override the methods to manage adding and removing overlays and annotations from the map.
This object must remain the primary delegate of its internal map view regardless of map SDK since it manages all overlays. However, the same map delegates for the specific map SDK are also proxied to other map view delegates as necessary.
-
The strategy type for the map strategy.
Declaration
Objective-C
@required @property (nonatomic, readonly) AWFMapStrategyType strategyType;
Swift
var strategyType: AWFMapStrategyType { get }
-
The map view being managed by the strategy.
The object returned by this property will depend on the type of map strategy and map SDK being used. For instance, {@link AWFAppleMapStrategy} will always return an instance of {@link MKMapView} for this property.
Declaration
Objective-C
@required @property (nonatomic, strong, readwrite) UIView *_Nonnull mapView;
Swift
var mapView: UIView { get set }
-
The weather map configuration associated with the weather map.
Declaration
Objective-C
@required @property (nonatomic, strong, readonly) AWFWeatherMapConfig *_Nonnull config;
Swift
var config: AWFWeatherMapConfig { get }
-
The factory object responsible for generating the map overlays and annotations required by the specific map strategy.
Declaration
Objective-C
@required @property (nonatomic, strong, readonly) id<AWFMapOverlayFactory> _Nonnull overlayFactory;
Swift
var overlayFactory: AWFMapOverlayFactory { get }
-
The map callout used for presenting data for a specific point or region on the map.
Declaration
Objective-C
@required @property (nonatomic, strong, readonly) AWFMapCallout *_Nonnull callout;
Swift
var callout: AWFMapCallout { get }
-
Returns an array of overlays currently active on the strategy’s map view (read-only).
Declaration
Objective-C
@required @property (nonatomic, strong, readonly) NSArray *_Nonnull overlays;
Swift
var overlays: [Any] { get }
-
Returns an array of annotations currently active on the strategy’s map view (read-only).
Declaration
Objective-C
@required @property (nonatomic, strong, readonly) NSArray *_Nonnull annotations;
Swift
var annotations: [Any] { get }
-
Returns the current visible coordinate bounds of the strategy’s map view (read-only).
Declaration
Objective-C
@required @property (nonatomic, readonly) AWFMapCoordinateBounds *_Nonnull coordinateBounds;
Swift
var coordinateBounds: AWFMapCoordinateBounds { get }
-
Returns the current center coordinate of the strategy’s map view (read-only).
Declaration
Objective-C
@required @property (nonatomic, readonly) CLLocationCoordinate2D centerCoordinate;
Swift
var centerCoordinate: CLLocationCoordinate2D { get }
-
Returns the current zoom level of the strategy’s map view (read-only).
Declaration
Objective-C
@required @property (nonatomic, readonly) NSInteger zoomLevel;
Swift
var zoomLevel: Int { get }
-
The internal view used for rendering animated tile and image data.
Declaration
Objective-C
@required @property (nonatomic, strong, readonly) id _Nonnull animationContainerView;
Swift
var animationContainerView: Any { get }
-
The receiver’s delegate.
The delegate should implement the methods of the
AWFMapStrategyDelegate
protocol.Declaration
Objective-C
@required @property (nonatomic, weak, readwrite, nullable) id<AWFMapStrategyDelegate> delegate;
Swift
weak var delegate: AWFMapStrategyDelegate? { get set }
-
Initializes and returns a map strategy associated with the specified weather map instance.
Declaration
Objective-C
- (nonnull instancetype)initWithWeatherMap:(nonnull AWFWeatherMap *)weatherMap;
Swift
init(weatherMap: AWFWeatherMap)
Parameters
weatherMap
The weather map instance associated with the map strategy.
Return Value
An initialized map strategy.
-
Adds a single overlay object to the map.
Declaration
Objective-C
- (void)addOverlay:(nonnull id)overlay;
Swift
func addOverlay(_ overlay: Any)
Parameters
overlay
The overlay object to add. This object can either be a subclass of
AWFOverlay
or a subclass of the overlay object expected by the specific map SDK being used. -
Adds an array of overlay objects to the map.
Declaration
Objective-C
- (void)addOverlays:(nonnull NSArray *)overlays;
Swift
func addOverlays(_ overlays: [Any])
Parameters
overlays
The array of overlay objects to add. These objects can either be a subclass of
AWFOverlay
or a subclass of the overlay object expected by the specific map SDK being used. -
Inserts an overlay object on the map at the specified index.
Declaration
Objective-C
- (void)insertOverlay:(nonnull id)overlay atIndex:(NSUInteger)index;
Swift
func insertOverlay(_ overlay: Any, at index: UInt)
Parameters
overlay
The overlay object to insert. This object can either be a subclass of
AWFOverlay
or a subclass of the overlay object expected by the specific map SDK being used.index
The index to which to insert the overlay object. If this value is greater than the number of overlays currently on the map, this method appends the object to the top of the overlays list.
-
Removes a single overlay object from the map.
Declaration
Objective-C
- (void)removeOverlay:(nonnull id)overlay;
Swift
func removeOverlay(_ overlay: Any)
Parameters
overlay
The overlay object to remove. This object can either be a subclass of
AWFOverlay
or a subclass of the overlay object expected by the specific map SDK being used. -
Removes an array of overlay objects from the map.
Declaration
Objective-C
- (void)removeOverlays:(nonnull NSArray *)overlays;
Swift
func removeOverlays(_ overlays: [Any])
Parameters
overlays
The overlay objects to remove. These objects can either be a subclass of
AWFOverlay
or a subclass of the overlay object expected by the specific map SDK being used. -
Returns the index of the overlay object in the overlays list on the map.
Declaration
Objective-C
- (NSInteger)indexForOverlay:(nonnull id)overlay;
Swift
func index(forOverlay overlay: Any) -> Int
Parameters
overlay
The overlay object to return the index for. This object can either be a subclass of
AWFOverlay
or a subclass of the overlay object expected by the specific map SDK being used.Return Value
The index of the overlay object in the overlays list, or
-1
if the overlay object is not on the map (in the overlays list). -
Forces an overlay to be reloaded and displayed.
Declaration
Objective-C
- (void)invalidateOverlay:(nonnull id)overlay;
Swift
func invalidateOverlay(_ overlay: Any)
Parameters
overlay
The overlay object whose content you want to draw.
-
Forces an array of overlays to be reloaded and displayed.
Declaration
Objective-C
- (void)invalidateOverlays:(nonnull NSArray *)overlays;
Swift
func invalidateOverlays(_ overlays: [Any])
Parameters
overlays
An array of overlay objects whose contents you want to draw.
-
Adds an annotation to the map.
Declaration
Objective-C
- (void)addAnnotation:(nonnull id)annotation;
Swift
func addAnnotation(_ annotation: Any)
-
Adds an array of annotations to the map.
Declaration
Objective-C
- (void)addAnnotations:(nonnull NSArray *)annotations;
Swift
func addAnnotations(_ annotations: [Any])
Parameters
annotations
The array of annotations to add. These objects should adopt the
AWFAnnotation
protocol and be a subclass instance of the annotation object expected by the specific map SDK being used. -
Removes an annotation from the map.
Declaration
Objective-C
- (void)removeAnnotation:(nonnull id)annotation;
Swift
func removeAnnotation(_ annotation: Any)
-
Removes an array of annotation from the map.
Declaration
Objective-C
- (void)removeAnnotations:(nonnull NSArray *)annotations;
Swift
func removeAnnotations(_ annotations: [Any])
Parameters
annotations
The array of annotations to remove. These objects should adopt the
AWFAnnotation
protocol and be a subclass instance of the annotation object expected by the specific map SDK being used. -
Selects the specified
annotation
.Declaration
Objective-C
- (void)selectAnnotation:(nonnull id)annotation;
Swift
func selectAnnotation(_ annotation: Any)
Parameters
annotation
The annotation to select
-
Selects the specified
annotation
.Declaration
Objective-C
- (void)selectAnnotation:(nonnull id)annotation animated:(BOOL)animated;
Swift
func selectAnnotation(_ annotation: Any, animated: Bool)
Parameters
annotation
The annotation to select
animated
Whether the selection should be animated.
-
Deselects the specified
annotation
.Declaration
Objective-C
- (void)deselectAnnotation:(nonnull id)annotation;
Swift
func deselectAnnotation(_ annotation: Any)
Parameters
annotation
The annotation to deselect.
-
Deselects the specified
annotations
Declaration
Objective-C
- (void)deselectAnnotation:(nonnull id)annotation animated:(BOOL)animated;
Swift
func deselectAnnotation(_ annotation: Any, animated: Bool)
Parameters
annotation
The annotation to deselect.
animated
Whether the deselection should be animated.
-
Deselects any currently selected annotation, if any.
Declaration
Objective-C
- (void)deselectCurrentlySelectedAnnotation;
Swift
func deselectCurrentlySelectedAnnotation()
-
Adds the annotation on the map for the long press gesture.
Declaration
Objective-C
- (void)showAnnotationForLongPressAtCoordinate: (CLLocationCoordinate2D)coordinate;
Swift
func showAnnotationForLongPress(at coordinate: CLLocationCoordinate2D)
Parameters
coordinate
The coordinate at which to add the annotation.
-
Removes the annotation for the long press gesture from the map.
Declaration
Objective-C
- (void)removeAnnotationForLongPress:(BOOL)animated;
Swift
func removeAnnotation(forLongPress animated: Bool)
Parameters
animated
YES
if the removal should be animated, otherwiseNO
and the annotation will be removed immediately.
-
Changes the center coordinate of the map and optionally animates the change.
Declaration
Objective-C
- (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate animated:(BOOL)animated;
Swift
func setCenter(_ centerCoordinate: CLLocationCoordinate2D, animated: Bool)
Parameters
centerCoordinate
The new center coordinate for the map.
animated
Specify
YES
if you want the map view to scroll to the new location orNO
if you want the map to display the new location immediately. -
Changes the center coordinate and zoom level of the map and optionally animates the change.
Declaration
Objective-C
- (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate zoomLevel:(NSUInteger)zoomLevel animated:(BOOL)animated;
Swift
func setCenter(_ centerCoordinate: CLLocationCoordinate2D, zoomLevel: UInt, animated: Bool)
Parameters
centerCoordinate
The new center coordinate for the map.
zoomLevel
The new zoom level for the map.
animated
Specify
YES
if you want the map view to scroll to the new location orNO
if you want the map to display the new location immediately. -
Converts a map coordinate to a point in the specified view.
Declaration
Objective-C
- (CGPoint)pointForCoordinate:(CLLocationCoordinate2D)coord inView:(nullable UIView *)view;
Swift
func point(for coord: CLLocationCoordinate2D, in view: UIView?) -> CGPoint
Parameters
coord
The map coordinate for which you want to find the corresponding point.
view
The view in whose coordinate system you want to locate the specified map coordinate. If this parameter is
nil
, the returned point is specified in the window’s coordinate system.Return Value
The point in the specified view or window coordinate system corresponding to the specified latitude and longitude value.
-
Converts a point in the specified view’s coordinate system to a map coordinate.
Declaration
Objective-C
- (CLLocationCoordinate2D)coordinateForPoint:(CGPoint)point inView:(nullable UIView *)view;
Swift
func coordinate(for point: CGPoint, in view: UIView?) -> CLLocationCoordinate2D
Parameters
point
The point you want to convert.
view
The view that serves as the reference coordinate system for the point parameter.
Return Value
The map coordinate at the specified point.
-
Returns a Boolean value indicating if the specified coordinate falls within the bounds of the
polygon
overlay.Declaration
Objective-C
- (BOOL)isCoordinate:(CLLocationCoordinate2D)coord withinPolygon:(nonnull id)polygon;
Swift
func isCoordinate(_ coord: CLLocationCoordinate2D, withinPolygon polygon: Any) -> Bool
Parameters
coord
The coordinate to test.
polygon
The polygon overlay to determine if the coordinate falls within
Return Value
YES
if the coordinate is contained within the polygon, otherwiseNO
. -
Forwards a tap gesture to the map strategy in order to determine if an overlay was tapped on the map.
Declaration
Objective-C
- (void)forwardTouchAtPoint:(CGPoint)touchPoint inView:(nonnull UIView *)view;
Swift
func forwardTouch(at touchPoint: CGPoint, in view: UIView)
Parameters
touchPoint
The point that was tapped on the map.
view
The view in which the tap gesture occurred.
-
Returns the default annotation view for the specified annotation as configured and styled by the SDK.
Declaration
Objective-C
- (nonnull id)defaultAnnotationViewForAnnotation:(nonnull id)annotation;
Swift
func defaultAnnotationView(forAnnotation annotation: Any) -> Any
Parameters
annotation
Annotation to return the default view for
-
Returns the default overlay renderer or layer for the specified overlay as configured and styled by the SDK. Note that not all mapping strategies support this method depending on how overlays are created and rendered by the third-party mapping library.
Declaration
Objective-C
- (nonnull id)defaultRendererForOverlay:(nonnull id)overlay;
Swift
func defaultRenderer(forOverlay overlay: Any) -> Any
Parameters
overlay
Overlay to return the renderer or layer for