Class

MKMapItem

A point of interest on the map.

Overview

A map item includes a geographic location and any interesting data that might apply to that location, such as the address at that location and the name of a business at that address. You can also use create a special MKMapItem object representing the user's current location.

Use this class to do the following:

  • Share map-related data with the Maps app.

  • Handle requests for directions that originate from the Maps app.

To display information in Maps, create an MKMapItem object with the information you want to display and call the openMaps(with:launchOptions:) method. Maps displays that location on the map and shows the information you provide.

If you implement a routing app, Maps provides you with two MKMapItem objects representing the start and end points. Use the information in those two objects to plot the route and generate directions.

Topics

Creating and Initializing Map Items

class func forCurrentLocation()

Creates and returns a singleton map item object representing the device’s current location.

init(placemark: MKPlacemark)

Initializes and returns a map item object using the specified placemark object.

Accessing the Map Item Attributes

var placemark: MKPlacemark

The placemark object containing the location information.

var isCurrentLocation: Bool

A Boolean value indicating whether the map item represents the user’s current location.

var name: String?

The descriptive name associated with the map item.

var phoneNumber: String?

The phone number associated with a business at the specified location.

var url: URL?

The URL associated with the specified location.

var timeZone: TimeZone?

The time zone of the specified location.

Launching the Maps App

class func openMaps(with: [MKMapItem], launchOptions: [String : Any]? = nil)

Open the Maps app and display the specified map items.

func openInMaps(launchOptions: [String : Any]? = nil)

Open the Maps app and display this map item.

Constants

Launch Options Dictionary Keys

Launch options to specify when opening map items in the Maps app.

Directions Mode Values

Strings representing the possible values of the MKLaunchOptionsDirectionsModeKey key.

See Also

Directions

class MKDirections

A utility object that computes directions and travel-time information based on the route information you provide.

class MKDirectionsRequest

The start and end points of a route, along with the planned mode of transportation.

class MKDirectionsResponse

The route information returned by Apple servers in response to one of your requests for directions.

class MKETAResponse

The travel-time information returned by Apple servers.

class MKRoute

A single route between a requested start and end point.

class MKRouteStep

One portion of an overall route.