BMMapView is the core class for embedding a map into an iOS app. More...
Public Member Functions | |
(void) | - setRegion:animated: |
Sets the region of the map, with an option to animate the transition. | |
(void) | - setCenterCoordinate:animated: |
Sets the center cordinate of the map, with an option to animate the transition. | |
(BMCoordinateRegion) | - regionThatFits: |
Adjusts the region to fit inside the map view. | |
(CGPoint) | - convertCoordinate:toPointToView: |
Converts a coordinate to a point in the specified view. | |
(CLLocationCoordinate2D) | - convertPoint:toCoordinateFromView: |
Converts a point in a view to a map coordinate. | |
(CGRect) | - convertRegion:toRectToView: |
Converts a region to a rectangle in the specified view. | |
(BMCoordinateRegion) | - convertRect:toRegionFromView: |
Converts a rectangle to a region. | |
(void) | - addMarker: |
Adds a marker to the map view. | |
(void) | - addMarkers: |
Adds markers to the map view. | |
(void) | - removeMarker: |
Removes a marker from the map view. | |
(void) | - removeMarkers: |
Removes markers from the map view. | |
(BMMarkerView *) | - viewForMarker: |
Returns the currently displayed view for a marker. | |
(BMMarkerView *) | - dequeueReusableMarkerViewWithIdentifier: |
Used by the delegate to acquire an already allocated marker view, in lieu of allocating a new one. | |
(void) | - selectMarker:animated: |
Selects a given marker, and shows its callout. | |
(void) | - deselectMarker:animated: |
Deselects a given marker, and hides its callout. | |
Properties | |
id< BMMapViewDelegate > | delegate |
The Map View's delegate. | |
BMMapMode | mapMode |
The Map Mode (BMMapModeRoad, BMMapModeAerial, or BMMapModeAerialWithLabels) of the map view. | |
BMCoordinateRegion | region |
The region (coordinate and span) displayed within the map view. | |
BOOL | zoomEnabled |
Indicates whether the user can use pinch gestures to zoom in and out of the map. | |
BOOL | scrollEnabled |
Indicates whether the user can scroll the map. | |
CLLocationCoordinate2D | centerCoordinate |
The coordinate of the map center. | |
BOOL | showsUserLocation |
Indicates if the map should display the location of the user. | |
BMUserLocation * | userLocation |
The BMUserLocation Marker object representing the location of the user. (read-only) | |
BOOL | userLocationVisible |
A Boolean value indicating whether the device's current location is visible in the map view. (read-only) | |
NSArray * | markers |
Array of markers for this map view. (read-only) | |
NSArray * | selectedMarkers |
The markers which are currently selected. | |
CGRect | markerVisibleRect |
Visible rectangle of the map view where the markers' views are currently displayed. (read-only) |
BMMapView is the core class for embedding a map into an iOS app.
A BMMapView is an interactive map view which inherits from UIView. The map view can be fitted to a map area, centred on a coordinate and display markers.
By default the map displays the entire world. When initializing the map view, the region property should be assigned or setRegion called to center the map on a specific region. It is recommended that this call be placed in the viewDidLoad method of the application to ensure the map view has been set by the time the call is made.
A region is a BMCoordinateRegion consisting of a center point and a horizontal and vertical span measured in longitude and latitude deltas. The span properties implicitly set a zoom level depending on their size.
Touch interactions with the map can be constrained by setting the properties scrollEnabled and zoomEnabled.
A delegate object of the map view informs an application implementing it of the changes in map status and marker view events.
You can add markers to the map view by using the BMMarkerView and BMPushpinView classes. See the description of these classes for more detail.
You can return a localized map by setting Region Format in the International settings menu.
- (void) addMarker: | (id <BMMarker>) | marker |
Adds a marker to the map view.
marker | The marker to add. |
- (void) addMarkers: | (NSArray *) | markers |
Adds markers to the map view.
markers | An array of markers to add. |
- (CGPoint) convertCoordinate: | (CLLocationCoordinate2D) | coordinate | |
toPointToView: | (UIView *) | view | |
Converts a coordinate to a point in the specified view.
coordinate | The coordinate to convert. |
view | The view. |
nil
, the returned point is relative to the window’s coordinate system. If view is not nil
, it must belong to the same window as the map view. - (CLLocationCoordinate2D) convertPoint: | (CGPoint) | point | |
toCoordinateFromView: | (UIView *) | view | |
Converts a point in a view to a map coordinate.
point | The point to convert. |
view | The view. |
nil
, the returned point is relative to the window’s coordinate system. If view is not nil
, it must belong to the same window as the map view. - (BMCoordinateRegion) convertRect: | (CGRect) | rect | |
toRegionFromView: | (UIView *) | view | |
Converts a rectangle to a region.
rect | The rectangle to convert. |
view | The view. |
nil
, the returned point is relative to the window’s coordinate system. - (CGRect) convertRegion: | (BMCoordinateRegion) | region | |
toRectToView: | (UIView *) | view | |
Converts a region to a rectangle in the specified view.
region | The region to convert. |
view | The view. |
nil
, the returned rectangle is relative to the window’s coordinate system. If view is not nil
, it must belong to the same window as the map view. - (BMMarkerView *) dequeueReusableMarkerViewWithIdentifier: | (NSString *) | identifier |
Used by the delegate to acquire an already allocated marker view, in lieu of allocating a new one.
identifier | The marker view to be reused. |
- (void) deselectMarker: | (id <BMMarker>) | marker | |
animated: | (BOOL) | animated | |
Deselects a given marker, and hides its callout.
Asks the delegate for the corresponding marker view if necessary.
marker | The marker to deselect. |
animated | Indicates whether to animate the marker deselection. |
- (BMCoordinateRegion) regionThatFits: | (BMCoordinateRegion) | region |
Adjusts the region to fit inside the map view.
region | The region that will be adjusted to fit within the map view. |
Referenced by setRegion:animated:.
- (void) removeMarker: | (id <BMMarker>) | marker |
Removes a marker from the map view.
marker | The marker to remove. |
- (void) removeMarkers: | (NSArray *) | markers |
Removes markers from the map view.
markers | An array of markers to remove. |
- (void) selectMarker: | (id <BMMarker>) | marker | |
animated: | (BOOL) | animated | |
Selects a given marker, and shows its callout.
Asks the delegate for the corresponding marker view if necessary.
marker | The marker to select. |
animated | Indicates whether to animate the marker selection. |
- (void) setCenterCoordinate: | (CLLocationCoordinate2D) | coordinate | |
animated: | (BOOL) | animated | |
Sets the center cordinate of the map, with an option to animate the transition.
coordinate | The new coordinate |
animated | Indicates whether to animate the transition. |
References delegate.
- (void) setRegion: | (BMCoordinateRegion) | region | |
animated: | (BOOL) | animated | |
Sets the region of the map, with an option to animate the transition.
region | The new region |
animated | Indicates whether to animate the transition. |
References delegate, and regionThatFits:.
- (BMMarkerView *) viewForMarker: | (id <BMMarker>) | marker |
Returns the currently displayed view for a marker.
marker | The marker object for which the view is being requested. |
- (CLLocationCoordinate2D) centerCoordinate [read, write, assign] |
The coordinate of the map center.
Changing this property re-centers the map on the new coordinate at the same zoom level.
- (id< BMMapViewDelegate >) delegate [read, write, assign] |
The Map View's delegate.
The delegate assigned to this property should implement the methods of the BMMapViewDelegate protocol. This delegate will be notified of map region and map data changes, and also information about marker views.
Referenced by setCenterCoordinate:animated:, and setRegion:animated:.
- (BMMapMode) mapMode [read, write, assign] |
The Map Mode (BMMapModeRoad, BMMapModeAerial, or BMMapModeAerialWithLabels) of the map view.
This property denotes what map style you want to show on the map view, for example, road, aerial or hybrid. Changing this property may cause new map tiles to load and display on the map.
- (NSArray *) markers [read, assign] |
Array of markers for this map view. (read-only)
The objects in this array must adopt the BMMarker protocol. If no Markers are associated with the map view, the value of this property is nil.
- (CGRect) markerVisibleRect [read, assign] |
Visible rectangle of the map view where the markers' views are currently displayed. (read-only)
The delegate can use markerVisibleRect when animating the adding of the markers views in mapView:didAddMarkerViews:
- (BMCoordinateRegion) region [read, write, assign] |
The region (coordinate and span) displayed within the map view.
A region has a coordinate (latitude and longitude) and a span. The coordinate is the value of the center position on the map. The span is the difference between the minimum and maximum latitudes and longitudes covered by the map. If you change the region, the map view updates accordingly. If you want to change only the coordinate without changing the current zoom level of the map view, use the centerCoordinate property, which ensures that the zoom level of the map view remains the same.
- (BOOL) scrollEnabled [read, write, assign] |
Indicates whether the user can scroll the map.
The default value is YES. If set to NO, the user will not be able to pan or scroll the map.
- (NSArray *) selectedMarkers [read, write, copy] |
The markers which are currently selected.
selectedMarkers Assigning a new array to this property selects the first marker in the array only.
- (BOOL) showsUserLocation [read, write, assign] |
Indicates if the map should display the location of the user.
showsUserLocation If this property is set to YES, the map view will use Core Location to find the current location, and will continue to update the user's location on th map until this property is set to NO. Not to be confused with userLocationVisible.
- (BMUserLocation *) userLocation [read, assign] |
The BMUserLocation Marker object representing the location of the user. (read-only)
userLocation
- (BOOL) userLocationVisible [read, assign] |
A Boolean value indicating whether the device's current location is visible in the map view. (read-only)
This property uses the horizontal accuracy of the current location to determine whether the user's location is visible. Thus, this property is YES if the specific coordinate is offscreen but the rectangle surrounding that coordinate (and defined by the horizontal accuracy value) is partially on the screen. If the user's location cannot be determined, this property contains the value NO.
- (BOOL) zoomEnabled [read, write, assign] |
Indicates whether the user can use pinch gestures to zoom in and out of the map.
The default value is YES. If set to NO, the user will not be able to zoom in or out of the currently programmed map region's zoom level.