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 *mapKeyDeclared 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 embeddedDeclared In
MRMapView.h
delegate
The delegate for this map view.
@property (nullable, nonatomic, weak) id<MRMapViewDelegate> delegateDiscussion
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)loadingParameters
loading |
If |
|---|
Declared In
MRMapView.h
showsPlacemarks
If YES (the default), the map’s placemarks will be displayed.
@property (nonatomic) BOOL showsPlacemarksDiscussion
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 showsTagsDiscussion
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 showsMapPickerDiscussion
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 showsDirectionsControlDiscussion
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 showsMapLabelDiscussion
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 showsOverviewButtonDiscussion
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 showsLocationButtonDiscussion
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 showsAccessibilityButtonDiscussion
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 showsBannerMessageDiscussion
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 default), the map will show the users’s current location when available. This may trigger
a request for “when in use” location authorization, which requires certain entries in your app’s Info.plist.
@property (nonatomic) BOOL showsUserLocationDeclared In
MRMapView.h
showsUserHeading
If YES (the default), the map will show the users’s current heading when available.
@property (nonatomic) BOOL showsUserHeadingDeclared 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 showsLocationAlertsDeclared In
MRMapView.h
showsWatermark
If YES (the default), the aruba watermark will appear at the top of the map
@property (nonatomic) BOOL showsWatermarkDeclared 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 ) longPressMapDeclared In
MRMapView.h
User annotations
annotations
The map’s annotations.
@property (nonnull, nonatomic, readonly) NSArray<id<MRAnnotation> > *annotationsDeclared In
MRMapView.h
placemarks
Placemark annotations (loaded automatically if showsPlacemark==YES).
@property (nonatomic, readonly, copy) NSArray<id<MRAnnotation> > *placemarksDeclared In
MRMapView.h
tagPredicate
A predicate for filtering visible tags.
@property (nullable, nonatomic, strong) NSPredicate *tagPredicateDeclared 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 MRDTagLabelSubscriptions are supported.
@property (nonnull, nonatomic, strong) NSArray<id<MRDTagSubscription> > *tagSubscriptionsDeclared In
MRMapView.h
userLocation
The annotation representing the user’s location.
@property (nonatomic, readonly, strong) MRUserLocation *userLocationDeclared In
MRMapView.h
selectedAnnotation
The currently selected annotation.
@property (nullable, nonatomic, readonly) id<MRAnnotation> selectedAnnotationDeclared In
MRMapView.h
selectedAnnotations
Array of currently selected annotations
@property (nullable, nonatomic, readonly) NSArray<id<MRAnnotation> > *selectedAnnotationsDeclared In
MRMapView.h
shouldClusterHighlightedAnnotations
If YES, annotations that are highlighted and collide will be clustered into a transient container annotation. Defaults to YES.
@property (nonatomic, assign) BOOL shouldClusterHighlightedAnnotationsDeclared In
MRMapView.h
highlightedAnnotations
Array of currently highlighted annotations. These annotations could also potentially be clustered.
@property (nonatomic, strong, readonly) NSArray<MRAnnotation> *highlightedAnnotationsDeclared In
MRMapView.h
visibleAnnotations
The annotations that are visible on the map.
@property (nonatomic, strong, readonly) NSArray<MRAnnotation> *visibleAnnotationsDeclared In
MRMapView.h
– addAnnotation:
Adds an annotation to the map.
- (void)addAnnotation:(id<MRAnnotation>)annotationParameters
annotation |
The annotation to add. |
|---|
Declared In
MRMapView.h
– addAnnotations:
Adds the provided annotations to the map.
- (void)addAnnotations:(NSArray<id<MRAnnotation> > *)annotationsParameters
annotations |
The annotations to add. |
|---|
Declared In
MRMapView.h
– removeAnnotation:
Removes an annotation from the map.
- (void)removeAnnotation:(id<MRAnnotation>)annotationParameters
annotation |
The annotation to remove. |
|---|
Declared In
MRMapView.h
– removeAnnotations:
Removes the specified annotations from the map.
- (void)removeAnnotations:(NSArray<id<MRAnnotation> > *)annotationsParameters
annotations |
The annotations to remove. |
|---|
Declared In
MRMapView.h
– selectAnnotation:animated:
Causes the specified annotation to become selected.
- (void)selectAnnotation:(nullable id<MRAnnotation>)annotation animated:(BOOL)animatedParameters
annotation |
The annotation to select. |
|---|---|
animated |
If YES, the selection will be animated. |
Declared In
MRMapView.h
– selectAnnotations:animated:
As of 5.8.0, multiple annotations can no longer have a selected state. What’s sent to this method will be highlighted. To display the annotations as a list in the bottom sheet, call MRMapViewController’s showAnnotationsInBottomSheet:
- (void)selectAnnotations:(nullable NSArray<id<MRAnnotation> > *)annotations animated:(BOOL)animatedParameters
annotations |
The annotations to highlight. |
|---|---|
animated |
If YES, the highlighting will be animated. |
Declared In
MRMapView.h
– deselectAnnotationAnimated:
Deselects the currently selected annotation.
- (void)deselectAnnotationAnimated:(BOOL)animatedParameters
animated |
If YES, the deselection will be animated. |
|---|
Declared In
MRMapView.h
– deselectAnnotations:animated:
As of 5.8.0, multiple annotations can no longer have a selected state. Calling this method will deselect the selected annotation, if there is one, and unhighlight the passed annotations.
- (void)deselectAnnotations:(nullable NSArray<id<MRAnnotation> > *)annotations animated:(BOOL)animatedParameters
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>)annotationParameters
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>)annotationParameters
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 *)identifierParameters
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 *)overlayParameters
overlay |
The overlay to add. |
|---|
Declared In
MRMapView.h
– addOverlays:
Adds the provided overlays to the map.
- (void)addOverlays:(NSArray<MRPathOverlay*> *)overlaysParameters
overlays |
The overlays to add. |
|---|
Declared In
MRMapView.h
– insertOverlay:atIndex:
Adds the provided overlay to the map.
- (void)insertOverlay:(MRPathOverlay *)overlay atIndex:(NSInteger)indexParameters
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 *)overlayParameters
overlay |
The overlay to remove. |
|---|
Declared In
MRMapView.h
– removeOverlays:
Removes the specified overlays from the map.
- (void)removeOverlays:(NSArray<MRPathOverlay*> *)overlaysParameters
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 *)overlayParameters
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)viewParameters
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)viewParameters
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)zoomParameters
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 visibleMapRectDeclared 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 ))completionParameters
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 rotationAngleDeclared In
MRMapView.h
zoomScale
Returns the map’s current zoom scale.
@property (nonatomic, readonly) CGFloat zoomScaleDeclared 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 ))completionParameters
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 ))completionParameters
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 *routeDeclared In
MRMapView.h
routeStepIndex
The step index of the current route.
@property (nonatomic, assign) NSUInteger routeStepIndexDeclared In
MRMapView.h
– setRoute:animated:
Sets the current route.
- (void)setRoute:(MRRoute *_Nullable)route animated:(BOOL)animatedParameters
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)animatedParameters
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)scrollToOverviewDeclared In
MRMapView.h
– setDirectionsControlVisible:
Shows or hides the directions control. Has no effect if showsDirectionsControl is set to NO.
- (void)setDirectionsControlVisible:(BOOL)visibleParameters
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 showsRoutePathDeclared In
MRMapView.h