MRMapView Class Reference
Inherits from | UIView |
---|---|
Declared in | MRMapView.h |
Overview
Provides an embeddable map interface, with support for displaying placemarks and routes as well as navigating between maps.
Creating and Configuring the map view
mapKey
The key that identifies this view’s map. Setting this property will cause the map view to load a new map.
@property (nonatomic, copy) MREditorKey *mapKey
Declared In
MRMapView.h
useLegacyAnnotationCallouts
Boolean property to determine if we should use legacy annotation callouts. Default value is @c NO
@property (nonatomic, assign) BOOL useLegacyAnnotationCallouts
Discussion
Note: It is recommended this property be set just after map view initialization. Manipulating this property after the map has been interacted with has undefined behavior
Declared In
MRMapView.h
embedded
Used to determine if the mapview is in a subview vs using the entire screen of a view controller. This is important for determining how the annotation detail sheet should be presented.
@property (nonatomic, assign, getter=isEmbedded) BOOL embedded
Declared In
MRMapView.h
delegate
The delegate for this map view.
@property (nullable, nonatomic, weak) id<MRMapViewDelegate> delegate
Discussion
You can set the map view’s delegate property to get callbacks when various map events occur. You can also customize map
annotations by implementing @c mapView:viewForAnnotation:. The delegate should adopt the MRMapViewDelegate
protocol.
Declared In
MRMapView.h
– setLoading:
Sets the loading state.
- (void)setLoading:(BOOL)loading
Parameters
loading |
If |
---|
Declared In
MRMapView.h
showsPlacemarks
If YES
(the default), the map’s placemarks will be displayed.
@property (nonatomic) BOOL showsPlacemarks
Discussion
Placemarks are displayed as map annotations, and are revealed and hidden as the user zooms in and out of the map.
Declared In
MRMapView.h
showsTags
If YES
, the map’s tags will be displayed. The default is NO
.
@property (nonatomic) BOOL showsTags
Discussion
Tags are displayed as map annotations, and are revealed and hidden as the user zooms in and out of the map.
Declared In
MRMapView.h
showsMapPicker
If YES
(the default), the map picker control will be displayed.
@property (nonatomic) BOOL showsMapPicker
Discussion
The map picker control allows users to navigate to other maps.
Declared In
MRMapView.h
showsDirectionsControl
If YES
(the default), the directions control will be displayed when a route is loaded.
@property (nonatomic) BOOL showsDirectionsControl
Discussion
The directions control allows users to see information about a route and traverse its steps.
Declared In
MRMapView.h
showsMapLabel
If YES
(the default), the map label will be displayed.
@property (nonatomic) BOOL showsMapLabel
Discussion
The map label indicates the map name and building name of the currently loaded map.
Declared In
MRMapView.h
showsOverviewButton
If YES
(the default), the overview button will be displayed.
@property (nonatomic) BOOL showsOverviewButton
Discussion
The overview button allows users to navigate to the overview map, if one exists.
Declared In
MRMapView.h
showsLocationButton
If YES
(the default), the location button will be displayed.
@property (nonatomic) BOOL showsLocationButton
Discussion
The location button allows the user to navigate to their current location on the map. If their location is on a different map, the map view will switch to the map that contains the user’s location.
Declared In
MRMapView.h
showsAccessibilityButton
If YES
(the default), the accessibility button will be visible when the map is displaying a route.
@property (nonatomic) BOOL showsAccessibilityButton
Discussion
The accessibility button allows the user to toggle a persistent preference to use either the shortest or the most accessible routes. Toggling the preference will cause the map to reload the currently displayed route.
Declared In
MRMapView.h
showsBannerMessage
If YES
(the default), the banner message will be displayed when required.
@property (nonatomic) BOOL showsBannerMessage
Discussion
The banner message is used to display relevant information in a banner (ex. “Reorient yourself to the directions line”)
Declared In
MRMapView.h
showsUserLocation
If YES
, the map will show the users’s current location when available. The default is NO
. This may trigger
a request for “when in use” location authorization, which requires certain entries in your app’s Info.plist.
@property (nonatomic) BOOL showsUserLocation
Declared In
MRMapView.h
showsUserHeading
If YES
(the default), the map will show the users’s current heading when available.
@property (nonatomic) BOOL showsUserHeading
Declared In
MRMapView.h
showsLocationAlerts
If YES
(the default), the user will be alerted about location failure or conditions that might preclude accurate readings.
@property (nonatomic) BOOL showsLocationAlerts
Declared In
MRMapView.h
showsWatermark
If YES
(the default), the aruba
watermark will appear at the top of the map
@property (nonatomic) BOOL showsWatermark
Declared In
MRMapView.h
longPressMap
Block to execute when the map is long pressed not on an annotation
pointOnMap
is the point on the map, in the maps coordinate system where it was long pressed
gestureState
is the gestures current state
Example use
@code
mapview.longPressMap = ^(CGPoint pointOnMap, UIGestureRecognizerState gestureState) {
NSLog(@“State - %@, Point - %@”, @(gestureState), NSStringFromCGPoint(pointOnMap));
};
@endcode
@property (nonatomic, copy, nullable) void ( ^ ) ( CGPoint pointOnMap , UIGestureRecognizerState gestureState ) longPressMap
Declared In
MRMapView.h
User annotations
annotations
The map’s annotations.
@property (nonnull, nonatomic, readonly) NSArray<id<MRAnnotation> > *annotations
Declared In
MRMapView.h
placemarks
Placemark annotations (loaded automatically if showsPlacemark==YES).
@property (nonatomic, readonly, copy) NSArray<id<MRAnnotation> > *placemarks
Declared In
MRMapView.h
tagPredicate
A predicate for filtering visible tags.
@property (nullable, nonatomic, strong) NSPredicate *tagPredicate
Declared In
MRMapView.h
tagSubscriptions
Tag Subscription(s) to show on the map.
While this property is an array, only a single MRDMapTagSubscription
or MRDTagIdentifierSubscription
are supported while a collection of MRDTagLabelSubscription
s are supported.
@property (nonnull, nonatomic, strong) NSArray<id<MRDTagSubscription> > *tagSubscriptions
Declared In
MRMapView.h
userLocation
The annotation representing the user’s location.
@property (nonatomic, readonly, strong) MRUserLocation *userLocation
Declared In
MRMapView.h
selectedAnnotation
The currently selected annotation.
@property (nullable, nonatomic, readonly) id<MRAnnotation> selectedAnnotation
Declared In
MRMapView.h
selectedAnnotations
Array of currently selected annotations
@property (nullable, nonatomic, readonly) NSArray<id<MRAnnotation> > *selectedAnnotations
Declared In
MRMapView.h
– addAnnotation:
Adds an annotation to the map.
- (void)addAnnotation:(id<MRAnnotation>)annotation
Parameters
annotation |
The annotation to add. |
---|
Declared In
MRMapView.h
– addAnnotations:
Adds the provided annotations to the map.
- (void)addAnnotations:(NSArray<id<MRAnnotation> > *)annotations
Parameters
annotations |
The annotations to add. |
---|
Declared In
MRMapView.h
– removeAnnotation:
Removes an annotation from the map.
- (void)removeAnnotation:(id<MRAnnotation>)annotation
Parameters
annotation |
The annotation to remove. |
---|
Declared In
MRMapView.h
– removeAnnotations:
Removes the specified annotations from the map.
- (void)removeAnnotations:(NSArray<id<MRAnnotation> > *)annotations
Parameters
annotations |
The annotations to remove. |
---|
Declared In
MRMapView.h
– selectAnnotation:animated:
Causes the specified annotation to become selected.
- (void)selectAnnotation:(id<MRAnnotation>)annotation animated:(BOOL)animated
Parameters
annotation |
The annotation to select. |
---|---|
animated |
If YES, the selection will be animated. |
Declared In
MRMapView.h
– selectAnnotations:animated:
Causes the specified annotations to become selected.
- (void)selectAnnotations:(nullable NSArray<id<MRAnnotation> > *)annotations animated:(BOOL)animated
Parameters
annotations |
The annotations to select. |
---|---|
animated |
If YES, the selection will be animated. |
Declared In
MRMapView.h
– deselectAnnotationAnimated:
Deselects the currently selected annotation.
- (void)deselectAnnotationAnimated:(BOOL)animated
Parameters
animated |
If YES, the deselection will be animated. |
---|
Declared In
MRMapView.h
– deselectAnnotations:animated:
Deselects the specified annotations selected annotation.
- (void)deselectAnnotations:(nullable NSArray<id<MRAnnotation> > *)annotations animated:(BOOL)animated
Parameters
annotations |
array of annotations to deselect or |
---|---|
animated |
If YES, the deselection will be animated. |
Declared In
MRMapView.h
– viewForAnnotation:
Returns the view for the currently displayed annotation; returns nil if the view for the annotation isn’t being displayed.
- (nullable MRAnnotationView *)viewForAnnotation:(id<MRAnnotation>)annotation
Parameters
annotation |
The annotation to whose view should be returned. |
---|
Declared In
MRMapView.h
– defaultViewForAnnotation:
Creates a new “default” annotation view for the given annotation.
- (MRAnnotationView *)defaultViewForAnnotation:(id<MRAnnotation>)annotation
Parameters
annotation |
The annotation to create a view for. |
---|
Discussion
Uses the mapping:
MRPlacemark
-> MRPlacemarkAnnotationView
The dequeueReusableAnnotationViewWithIdentifier:
method will be used internally automatically.
Declared In
MRMapView.h
– dequeueReusableAnnotationViewWithIdentifier:
Returns a reusable annotation view located by its identifier.
- (nullable MRAnnotationView *)dequeueReusableAnnotationViewWithIdentifier:(NSString *)identifier
Parameters
identifier |
A string identifying the annotation view to be reused. |
---|
Declared In
MRMapView.h
Overlays
– addOverlay:
Adds an overlay to the map.
- (void)addOverlay:(MRPathOverlay *)overlay
Parameters
overlay |
The overlay to add. |
---|
Declared In
MRMapView.h
– addOverlays:
Adds the provided overlays to the map.
- (void)addOverlays:(NSArray<MRPathOverlay*> *)overlays
Parameters
overlays |
The overlays to add. |
---|
Declared In
MRMapView.h
– insertOverlay:atIndex:
Adds the provided overlay to the map.
- (void)insertOverlay:(MRPathOverlay *)overlay atIndex:(NSInteger)index
Parameters
overlay |
The overlay to add. |
---|---|
index |
The z-index at which to display the overlay |
Declared In
MRMapView.h
– removeOverlay:
Removes an overlay from the map.
- (void)removeOverlay:(MRPathOverlay *)overlay
Parameters
overlay |
The overlay to remove. |
---|
Declared In
MRMapView.h
– removeOverlays:
Removes the specified overlays from the map.
- (void)removeOverlays:(NSArray<MRPathOverlay*> *)overlays
Parameters
overlays |
The overlays to remove. |
---|
Declared In
MRMapView.h
– rendererForOverlay:
Returns the renderer for the currently displayed overlay; returns nil if the renderer for the overlay isn’t being displayed.
- (MRPathRenderer *)rendererForOverlay:(MRPathOverlay *)overlay
Parameters
overlay |
The overlay to whose renderer should be returned. |
---|
Declared In
MRMapView.h
Converting Map Coordinates
– convertMapPoint:toPointToView:
Converts a point from the coordinate space of the map to the coordinate space of the specified view.
- (CGPoint)convertMapPoint:(CGPoint)point toPointToView:(UIView *_Nullable)view
Parameters
point |
The point on this map to convert. |
---|---|
view |
The view whose coordinate space the point should be converted to. |
Declared In
MRMapView.h
– convertPoint:toMapPointFromView:
Converts a point from the coordinate space of the specified view to the coordinate space of this map.
- (CGPoint)convertPoint:(CGPoint)point toMapPointFromView:(UIView *_Nullable)view
Parameters
point |
The point on this map to convert. |
---|---|
view |
The view whose coordinate space the point should be converted from. |
Declared In
MRMapView.h
– rectWithCenter:zoomLevel:
Returns a rectangle centered on the specified point and sized according to the specified zoom level.
- (CGRect)rectWithCenter:(CGPoint)center zoomLevel:(MRZoomLevel)zoom
Parameters
center |
The point at which to place the rectangle’s center. |
---|---|
zoom |
The zoom level to use when determining the rectangle’s size. |
Declared In
MRMapView.h
Changing the Visible Portion of the Map
visibleMapRect
Describes the visible portion of the map. Changing this property will update the map view immediately.
@property (nonatomic) CGRect visibleMapRect
Declared In
MRMapView.h
– setVisibleMapRect:animated:completion:
Updates the currently visible portion of the map, optionally animating the change.
- (void)setVisibleMapRect:(CGRect)mapRect animated:(BOOL)animated completion:(void ( ^ _Nullable ) ( void ))completion
Parameters
mapRect |
The rectangle describing the part of the map that should be visible. |
---|---|
animated |
If |
completion |
If animating, the block to call when animation completes. |
Declared In
MRMapView.h
rotationAngle
Returns the map’s current angle of rotation, in radians.
@property (nonatomic, readonly) CGFloat rotationAngle
Declared In
MRMapView.h
zoomScale
Returns the map’s current zoom scale.
@property (nonatomic, readonly) CGFloat zoomScale
Declared In
MRMapView.h
– setRotationAngle:animated:completion:
Updates the currently visible portion of the map, optionally animating the change.
- (void)setRotationAngle:(CGFloat)angle animated:(BOOL)animated completion:(void ( ^ _Nullable ) ( void ))completion
Parameters
angle |
The angle, in radians, the map’s angle will become. |
---|---|
animated |
If |
completion |
If animating, the block to call when animation completes. |
Declared In
MRMapView.h
– setVisibleMapRect:rotationAngle:animated:completion:
Updates the currently visible portion of the map, optionally animating the change.
- (void)setVisibleMapRect:(CGRect)visibleRect rotationAngle:(CGFloat)angle animated:(BOOL)animated completion:(void ( ^ _Nullable ) ( void ))completion
Parameters
visibleRect |
The rectangle describing the part of the map that should be visible. |
---|---|
angle |
The angle, in radians, the map’s angle will become. |
animated |
If |
completion |
If animating, the block to call when animation completes. |
Declared In
MRMapView.h
Directions support
route
The current route being displayed.
@property (nullable, nonatomic, strong) MRRoute *route
Declared In
MRMapView.h
routeStepIndex
The step index of the current route.
@property (nonatomic, assign) NSUInteger routeStepIndex
Declared In
MRMapView.h
– setRoute:animated:
Sets the current route.
- (void)setRoute:(MRRoute *_Nullable)route animated:(BOOL)animated
Parameters
route |
The route to display. |
---|---|
animated |
If YES, the transition to this route will be animated. |
Declared In
MRMapView.h
– setRouteStepIndex:animated:
Sets the step index for the current route.
- (void)setRouteStepIndex:(NSUInteger)index animated:(BOOL)animated
Parameters
index |
The index of the desired step. |
---|---|
animated |
If YES, the transition to the new step will be animated. |
Declared In
MRMapView.h
– scrollToOverview
Zooms and pans the map so that the whole route for the current map can be seen.
- (void)scrollToOverview
Declared In
MRMapView.h
– setDirectionsControlVisible:
Shows or hides the directions control. Has no effect if showsDirectionsControl
is set to NO
.
- (void)setDirectionsControlVisible:(BOOL)visible
Parameters
visible |
Whether or not the directions control should be displayed. |
---|
Declared In
MRMapView.h
showsRoutePath
If YES
(the default), the route path will be displayed.
@property (nonatomic) BOOL showsRoutePath
Declared In
MRMapView.h