Class: MKMapItem

Inherits:
NSObject show all

Overview

The MKMapItem class encapsulates information about a specific point on a map. This information includes the map location and any other data that might be relevant, such as the name of a business at that location. Apps use this class to share map-related data with the Maps app.

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from NSObject

#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version

Constructor Details

This class inherits a constructor from NSObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NSObject

Instance Attribute Details

- (Boolean) isCurrentLocation (readonly)

A Boolean value indicating whether the map item represents the user’s current location. If the value of this property is YES, the map item represents the user’s current location. If YES, the value in the placemark property is set to nil.

Returns:

  • (Boolean)

- (String) name

The descriptive name associated with the map item. Use this property to specify the name associated with the location. For example, if there is a business at the specified location, you would use this property to specify the name of the business.If this map item represents the user’s current location, the value in property is set to a localized version of “Current Location”.

Returns:

- (String) phoneNumber

The phone number associated with a business at the specified location. If there is a relevant phone number associated with the location, such as a phone number for a business at the location, use this property to specify that value.

Returns:

- (MKPlacemark) placemark (readonly)

The placemark object containing the location information. If you created the map item using the mapItemForCurrentLocation method, the value of this property is nil and the isCurrentLocation property is set to YES.

Returns:

- (NSURL) url

The URL associated with the specified location. If there is a relevant URL associated with the location, such as a URL for a business at the location, use this property to specify that value.

Returns:

Class Method Details

+ (MKMapItem) mapItemForCurrentLocation

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

Returns:

+ (Boolean) openMapsWithItems(mapItems, launchOptions:launchOptions)

Open the Maps app and display the specified map items. You use this method to pass one or more map items to the Maps app. For example, you might use this method to ask the Maps app to display location-based search results generated by your app. Maps displays pins at each location you specify and uses the contents of each map item object to display additional information.If you specify the MKLaunchOptionsDirectionsModeKey option in the launchOptions dictionary, the mapItems array must have no more than two items in it. If the array contains one item, the Maps app generates directions from the user’s current location to the location specified by the map item. If the array contains two items, the Maps app generates directions from the location of the first item to the location of the second item in the array.If you do not include the MKLaunchOptionsMapCenterKey and MKLaunchOptionsMapSpanKey keys in your launchOptions dictionary, Maps constructs a region that encompasses the provided items. It uses this region to set the visible portion of the map.

Parameters:

  • mapItems (Array)

    An array containing one or more MKMapItem objects representing the items you want to display on the map. This parameter may be nil.

  • launchOptions (Hash)

    Additional information that the Maps app can use to configure the map display. For example, you can use the launch options to specify the visible map region and the map type. For a list of keys you can put into this dictionary, see “Launch Options Dictionary Keys”. You may specify nil for this parameter.

Returns:

  • (Boolean)

    YES if the map items were successfully opened by the Maps app, or NO if there was an error.

Instance Method Details

- (Object) initWithPlacemark(placemark)

Initializes and returns a map item object using the specified placemark object. Use this method to create a map item for an existing placemark. Do not use it to create a map item representing the user’s current location. To do that, use the mapItemForCurrentLocation method instead.

Parameters:

  • placemark (MKPlacemark)

    The placemark object corresponding to the desired map location. This parameter must not be nil.

Returns:

  • (Object)

    An initialized map item object.

- (Boolean) openInMapsWithLaunchOptions(launchOptions)

Open the Maps app and display this map item. You use this method to pass the current map item to the Maps app. If your map item contains descriptive information about the location (such as a name or URL), the Maps app displays that information at the specified coordinate.If you specify the MKLaunchOptionsDirectionsModeKey option in the launchOptions dictionary, the Maps app interprets that as an attempt to map from the user’s current location to the location specified by this map item.If you do not include the MKLaunchOptionsMapCenterKey and MKLaunchOptionsMapSpanKey keys in your launchOptions dictionary, Maps constructs a region around the current item. It uses that region to set the visible portion of the map.

Parameters:

  • launchOptions (Hash)

    Additional information that the Maps app can use to configure the map display. For example, you can use the launch options to specify the visible map region and the map type. For a list of keys you can put into this dictionary, see “Launch Options Dictionary Keys”. This parameter may be nil.

Returns:

  • (Boolean)

    YES if this map item was successfully opened by the Maps app, or NO if there was an error.