Public Member Functions | Properties

BMMapView Class Reference

BMMapView is the core class for embedding a map into an iOS app. More...

List of all members.

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< BMMapViewDelegatedelegate
 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.
BMUserLocationuserLocation
 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)

Detailed Description

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.


Member Function Documentation

- (void) addMarker: (id <BMMarker>)  marker

Adds a marker to the map view.

Parameters:
markerThe marker to add.
See also:
- addMarkers:
- removeMarker:
- removeMarkers:
- (void) addMarkers: (NSArray *)  markers

Adds markers to the map view.

Parameters:
markersAn array of markers to add.
See also:
- addMarker:
- removeMarker:
- removeMarkers:
- (CGPoint) convertCoordinate: (CLLocationCoordinate2D)  coordinate
toPointToView: (UIView *)  view 

Converts a coordinate to a point in the specified view.

Parameters:
coordinateThe coordinate to convert.
viewThe view.
Returns:
A point
Remarks:
If view is 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.

Parameters:
pointThe point to convert.
viewThe view.
Returns:
A coordinate
Remarks:
If view is 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.

Parameters:
rectThe rectangle to convert.
viewThe view.
Returns:
A region
Remarks:
If view is 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.

Parameters:
regionThe region to convert.
viewThe view.
Returns:
A rectangle
Remarks:
If view is 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.

Parameters:
identifierThe marker view to be reused.
Returns:
A marker view, or nil if no such object exists.
- (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.

Parameters:
markerThe marker to deselect.
animatedIndicates whether to animate the marker deselection.
See also:
- selectMarker:animated:
- (BMCoordinateRegion) regionThatFits: (BMCoordinateRegion region

Adjusts the region to fit inside the map view.

Parameters:
regionThe region that will be adjusted to fit within the map view.
Returns:
A region, centered on the original point, adjusted to fit in the map view.

Referenced by setRegion:animated:.

- (void) removeMarker: (id <BMMarker>)  marker

Removes a marker from the map view.

Parameters:
markerThe marker to remove.
See also:
- addMarker:
- addMarkers:
- removeMarkers:
- (void) removeMarkers: (NSArray *)  markers

Removes markers from the map view.

Parameters:
markersAn array of markers to remove.
See also:
- addMarker:
- addMarkers:
- removeMarker:
- (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.

Parameters:
markerThe marker to select.
animatedIndicates whether to animate the marker selection.
See also:
- deselectMarker:animated:
- (void) setCenterCoordinate: (CLLocationCoordinate2D)  coordinate
animated: (BOOL)  animated 

Sets the center cordinate of the map, with an option to animate the transition.

Parameters:
coordinateThe new coordinate
animatedIndicates whether to animate the transition.
See also:
centerCoordinate
- setRegion:animated:

References delegate.

- (void) setRegion: (BMCoordinateRegion region
animated: (BOOL)  animated 

Sets the region of the map, with an option to animate the transition.

Parameters:
regionThe new region
animatedIndicates whether to animate the transition.
See also:
centerCoordinate
- setCenterCoordinate:animated:

References delegate, and regionThatFits:.

- (BMMarkerView *) viewForMarker: (id <BMMarker>)  marker

Returns the currently displayed view for a marker.

Parameters:
markerThe marker object for which the view is being requested.
Returns:
The marker view, or nil if the view for the marker hasn't been created yet. May also return nil if the marker is not within the visible map region.

Property Documentation

- (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.

See also:
- setCenterCoordinate:animated:
- (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.

See also:
- addMarker:
- addMarkers:
- removeMarker:
- removeMarkers:
- (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.

See also:
- regionThatFits:
- setRegion:animated:
- (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.

See also:
- selectMarker:animated:
- (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.

See also:
userLocationVisible
userLocation
- (BMUserLocation *) userLocation [read, assign]

The BMUserLocation Marker object representing the location of the user. (read-only)

userLocation

See also:
showsUserLocation
userLocationVisible
BMUserLocation
- (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.


The documentation for this class was generated from the following files: