MKMapView(AerisMapKit)

@interface MKMapView (AerisMapKit)

Extensions and utility methods for MKMapView.

  • Returns the current zoom level as an integer from 1 to 20 based on the map’s current zoom scale and region.

    Declaration

    Objective-C

    - (NSUInteger)awf_zoomLevel;

    Swift

    func awf_zoomLevel() -> UInt

    Return Value

    The current zoom level

  • Returns the current zoom scale for the map.

    Declaration

    Objective-C

    - (MKZoomScale)awf_zoomScale;

    Swift

    func awf_zoomScale() -> MKZoomScale

    Return Value

    The current zoom scale

  • Sets the map’s center coordinate and zoom level.

    Declaration

    Objective-C

    - (void)awf_setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate
                          zoomLevel:(NSUInteger)zoomLevel
                           animated:(BOOL)animated;

    Swift

    func awf_setCenter(_ centerCoordinate: CLLocationCoordinate2D, zoomLevel: UInt, animated: Bool)

    Parameters

    centerCoordinate

    The center coordinate for the map

    zoomLevel

    The zoom level

    animated

    A Boolean indicating whether or not the change should be animated

  • Returns a new coordinate based on a coordinate, point offset and zoom level regardless of the map’s current zoom level.

    Declaration

    Objective-C

    - (CLLocationCoordinate2D)
        awf_coordinateByOffsettingCenterCoordinate:
            (CLLocationCoordinate2D)centerCoordinate
                                            offset:(UIOffset)offset
                                         zoomLevel:(NSUInteger)zoomLevel;

    Swift

    func awf_coordinate(byOffsettingCenter centerCoordinate: CLLocationCoordinate2D, offset: UIOffset, zoomLevel: UInt) -> CLLocationCoordinate2D

    Parameters

    centerCoordinate

    The coordinate from which to calculate the offset from

    offset

    The pixel offset from the coordinate

    zoomLevel

    The zoom level to use for the calculation

    Return Value

    A new coordinate that is offset pixels from centerCoordinate for the given zoomLevel

Coordinate Bounds

  • Returns the northwest (top-left) coordinate of the visible map bounds.

    Declaration

    Objective-C

    - (CLLocationCoordinate2D)awf_northwestCoordinate;

    Swift

    func awf_northwestCoordinate() -> CLLocationCoordinate2D

    Return Value

    CLLocationCoordinate2D

  • Returns the southwest (bottom-left) coordinate of the visible map bounds.

    Declaration

    Objective-C

    - (CLLocationCoordinate2D)awf_southwestCoordinate;

    Swift

    func awf_southwestCoordinate() -> CLLocationCoordinate2D

    Return Value

    CLLocationCoordinate2D

  • Returns the northeast (top-right) coordinate of the visible map bounds.

    Declaration

    Objective-C

    - (CLLocationCoordinate2D)awf_northeastCoordinate;

    Swift

    func awf_northeastCoordinate() -> CLLocationCoordinate2D

    Return Value

    CLLocationCoordinate2D

  • Returns to southeast (bottom-right) coordinate of the visible map bounds.

    Declaration

    Objective-C

    - (CLLocationCoordinate2D)awf_southeastCoordinate;

    Swift

    func awf_southeastCoordinate() -> CLLocationCoordinate2D

    Return Value

    CLLocationCoordinate2D

Map Tiles

  • Returns a map tile’s x and y grid locations that a coordinate falls within at the specified zoom level.

    The tile grid location calculations are based on the standard 256x256 tile sizes that most mapping APIs use. The zoom level should be a value from 1 to 20 and is based on the map’s zoom scale. You can retrieve the map’s current zoom level using the awf_zoomLevel category method provided.

    Declaration

    Objective-C

    - (CGPoint)awf_tileXYForCoordinate:(CLLocationCoordinate2D)coord
                             zoomLevel:(NSUInteger)zoomLevel;

    Swift

    func awf_tileXY(for coord: CLLocationCoordinate2D, zoomLevel: UInt) -> CGPoint

    Parameters

    coord

    The coordinate to use when determining the tile grid location

    zoomLevel

    The map zoom level to use in determining the tile grid location

    Return Value

    The tile’s x and y grid location to be used when requesting the proper tile.

  • Calculates the coordinate bounds at the corners of the tile at a specific grid location and zoom level.

    Declaration

    Objective-C

    - (nonnull AWFMapCoordinateBounds *)af_coordinateBoundsForTileAtX:(NSUInteger)x
                                                                    y:(NSUInteger)y;

    Swift

    func af_coordinateBoundsForTileAt(x: UInt, y: UInt) -> AWFMapCoordinateBounds

    Parameters

    x

    The tile’s x coordinate.

    y

    The tile’s y coordinate.

    Return Value

    An AWFMapCoordinateBounds instance with the calculated coordinates for the four corners and center.