### Get the route's starting point Source: https://developer.apple.com/documentation/mapkit/mkdirections/etaresponse/source Access the starting point of the route using the 'source' property. This property returns an MKMapItem object. ```swift var source: MKMapItem { get } ``` -------------------------------- ### init(tileOverlay:) Source: https://developer.apple.com/documentation/mapkit/mktileoverlayrenderer/init%28tileoverlay%3A%29 Initializes and returns a tile renderer with the specified overlay object. ```APIDOC ## init(tileOverlay:) ### Description Initializes and returns a tile renderer with the specified overlay object. The returned renderer object works with the tile overlay object to coordinate the loading and display of its map tiles. ### Parameters #### Path Parameters - **overlay** (MKTileOverlay) - Required - The tile overlay object whose contents you want to draw. ### Return Value An initialized tile renderer object. ``` -------------------------------- ### Example Usage of DirectionsRequest Source: https://developer.apple.com/documentation/mapkitjs/directionsrequest This example demonstrates how to create a `DirectionsRequest` object and use it with the `route()` method to get directions between San Francisco and Oakland by automobile. ```APIDOC ## Example Usage ### Description Provide a `DirectionsRequest` object to the `route(request, callback)` method to get directions between two points. ### Request Example ```javascript const myDirections = new mapkit.Directions(); myDirections.route({ origin: "San Francisco, CA", destination: "Oakland, CA", transportType: mapkit.TransportType.Automobile }, function(error, data) { // Results return asynchronously via this callback function, in `data`. }); ``` ``` -------------------------------- ### Using showItems to Display Annotations Source: https://developer.apple.com/documentation/mapkitjs/map/showitems Example demonstrating how to initialize marker annotations and display them on the map with animation and padding. ```javascript const park = new mapkit.MarkerAnnotation(new mapkit.Coordinate(37.749581, -119.524212), { title: "Yosemite" }), surf = new mapkit.MarkerAnnotation(new mapkit.Coordinate(37.49557, -122.496687), { title: "Mavericks" }); map.showItems([park, surf], { animate: true, padding: new mapkit.Padding(60, 25, 60, 25) }); ``` -------------------------------- ### GET MKDirections.Response.routes Source: https://developer.apple.com/documentation/mapkit/mkdirections/response/routes Accesses the array of route objects representing the directions between the start and end points. ```APIDOC ## GET MKDirections.Response.routes ### Description An array of route objects representing the directions between the start and end points. The array contains one or more MKRoute objects, each representing a possible set of directions. ### Response - **routes** (Array) - An array of route objects. If alternate routes were not requested, this array contains at most one object. ``` -------------------------------- ### start(with:completionHandler:) - Async/Await Source: https://developer.apple.com/documentation/mapkit/mkmapsnapshotter/start%28with%3Acompletionhandler%3A%29 Submits the request to create a snapshot using async/await syntax. This method throws an error if the snapshot creation fails. ```APIDOC ## func start(with:completionHandler:) async throws -> MKMapSnapshotter.Snapshot ### Description Submits the request to create a snapshot and executes the resulting block on the specified queue using async/await. ### Method func ### Endpoint N/A (Instance Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) Returns an `MKMapSnapshotter.Snapshot` object upon successful creation. #### Response Example None ### Error Handling Throws an error if the snapshot creation fails. ``` -------------------------------- ### Get and set strokeStart Source: https://developer.apple.com/documentation/mapkitjs/style/strokestart Access or modify the starting point of a polyline stroke. The value must be between 0 and 1. ```typescript get strokeStart(): number; set strokeStart(strokeStart: number); ``` -------------------------------- ### Method: start(completionHandler:) Source: https://developer.apple.com/documentation/mapkit/mklocalsearch/start%28completionhandler%3A%29 Initiates a local search operation and handles the results via a completion handler or async/await. ```APIDOC ## start(completionHandler:) ### Description Starts the search and delivers the results to the specified completion handler. ### Parameters #### Path Parameters - **completionHandler** (block) - Required - The completion handler block that processes the results. This parameter cannot be nil. ### Request Example ```swift func start(completionHandler: @escaping @MainActor @Sendable (MKLocalSearch.Response?, (any Error)?) -> Void) ``` ### Response #### Success Response - **MKLocalSearch.Response** (object) - The search results returned to the completion handler. - **Error** (object) - An error object if the search fails. ``` -------------------------------- ### init(scene:allowsNavigation:showsRoadLabels:pointsOfInterest:badgePosition:) Source: https://developer.apple.com/documentation/mapkit/lookaroundpreview/init%28scene%3Aallowsnavigation%3Ashowsroadlabels%3Apointsofinterest%3Abadgeposition%3A%29 Creates a Look Around preview with a binding to a scene, navigation, road label, points of interest, and badge position. ```APIDOC ## init(scene:allowsNavigation:showsRoadLabels:pointsOfInterest:badgePosition:) ### Description Creates a Look Around preview with a binding to a scene, navigation, road label, points of interest, and badge position you specify. ### Parameters - **scene** (Binding) - Required - A binding to the Look Around scene to display. - **allowsNavigation** (Bool) - Optional - Indicates whether the Look Around scene allows navigation after the user taps the preview to enter the full screen viewer. - **showsRoadLabels** (Bool) - Optional - Indicates whether the Look Around scene shows road labels after the user taps the preview to enter the full screen viewer. - **pointsOfInterest** (PointOfInterestCategories) - Optional - The categories of points of interest to display after the user taps the preview to enter the full screen viewer. - **badgePosition** (MKLookAroundBadgePosition) - Optional - A value that controls the position of a badge on the Look Around preview. ``` -------------------------------- ### Get and Set legendAlignment Source: https://developer.apple.com/documentation/mapkit/mkscaleview/legendalignment Use this property to determine whether measurements start at the leading or trailing edge of the view. The default value is MKScaleView.Alignment.leading. ```swift var legendAlignment: MKScaleView.Alignment { get set } ``` -------------------------------- ### Getting Estimated Arrival Times Source: https://developer.apple.com/documentation/mapkitjs/etaresult Use the `eta` function to retrieve estimated arrival times to multiple destinations from a single starting point. ```APIDOC ## Getting Estimated Arrival Times ### Description Retrieves estimated arrival times to up to 10 destinations from a single starting point. ### Function Signature `eta(request, callback)` ### Related Interfaces - `EtaRequestOptions`: The options you may provide for requesting estimated arrival times. - `EtaResponse`: The estimated arrival times for a set of destinations. ``` -------------------------------- ### init(_:) Source: https://developer.apple.com/documentation/mapkit/mkmultipolyline/init%28_%3A%29 Initializes a new MKMultiPolyline object using an array of MKPolyline objects. ```APIDOC ## init(_:) ### Description Creates a multipolyline object using the provided polylines. ### Parameters #### Path Parameters - **polylines** ([MKPolyline]) - Required - An array of MKPolyline objects to initialize the object with. ### Request Example init(_ polylines: [MKPolyline]) ``` -------------------------------- ### Retrieve Estimated Arrival Times with eta Source: https://developer.apple.com/documentation/mapkitjs/directions/eta Use this method to get estimated arrival times to up to 10 destinations from a single starting point. The results are returned asynchronously via a callback function. ```typescript eta( request: EtaRequestOptions, callback: (error: Error | null, result?: EtaResponse) => void, ): number | undefined; ``` -------------------------------- ### init(x:y:z:contentScaleFactor:) Source: https://developer.apple.com/documentation/mapkit/mktileoverlaypath/init%28x%3Ay%3Az%3Acontentscalefactor%3A%29 Creates a new overlay path with the specified indexes and content scale factor. ```APIDOC ## INITIALIZER init(x:y:z:contentScaleFactor:) ### Description Creates a new overlay path with the specified indexes and content scale factor. ### Parameters - **x** (Int) - The index of the tile along the x-axis of the map. - **y** (Int) - The index of the tile along the y-axis of the map. - **z** (Int) - The index of the tile along the z-axis of the map. - **contentScaleFactor** (CGFloat) - The screen scale that the framework shows the tile. This value is typically either 1.0 (for standard resolution displays) or 2.0 (for Retina displays). ``` -------------------------------- ### init(scene:) Source: https://developer.apple.com/documentation/mapkit/mklookaroundviewcontroller/init%28scene%3A%29 Initializes a new LookAround view controller using a specified scene. ```APIDOC ## init(scene:) ### Description Creates a new LookAround view controller with the specified scene. ### Parameters #### Parameters - **scene** (MKLookAroundScene) - Required - A MKLookAroundScene object. ### Request Example init(scene: myLookAroundScene) ``` -------------------------------- ### Get Full Address String Source: https://developer.apple.com/documentation/mapkit/mkaddress/fulladdress Access the `fullAddress` property to retrieve the complete address of a location as a string. This property is available on iOS, iPadOS, macOS, tvOS, visionOS, and watchOS starting from version 26.0. ```swift var fullAddress: String { get } ``` -------------------------------- ### init(coder:) Source: https://developer.apple.com/documentation/mapkit/mkmapview/cameraboundary-swift.class/init%28coder%3A%29 Initializes a new camera boundary instance from data in a given unarchiver. ```APIDOC ## init(coder:) ### Description Creates a camera boundary using the provided coder. ### Parameters #### Path Parameters - **coder** (NSCoder) - Required - The decoder to use during initialization. ### Request Example init?(coder: NSCoder) ``` -------------------------------- ### Guides API Source: https://developer.apple.com/documentation/mapkit/unified-map-urls Retrieve details about place guides and curated collections. ```APIDOC ## Guides API ### Endpoint `https://maps.apple.com/guides` ### Description Use the `/guides` path component to ask Maps to provide details about place guides and curated collections. ``` -------------------------------- ### init(nibName:bundle:) Source: https://developer.apple.com/documentation/mapkit/mklookaroundviewcontroller/init%28nibname%3Abundle%3A%29 Creates a new LookAround view controller from the specified nib and bundle. ```APIDOC ## init(nibName:bundle:) ### Description Creates a new LookAround view controller from the specified nib and bundle. ### Parameters - **nibNameOrNil** (String?) - Optional - The name of the nib file. - **nibBundleOrNil** (Bundle?) - Optional - The Bundle file. ### Request Example init(nibName: "MyLookAroundView", bundle: Bundle.main) ``` -------------------------------- ### MKReverseGeocodingRequest Example Usage Source: https://developer.apple.com/documentation/mapkit/mkreversegeocodingrequest Example of how to use MKReverseGeocodingRequest within a SwiftUI view to reverse geocode an array of coordinates. ```APIDOC ## Example Usage ```swift struct MyReverseGeocoderView: View { let fountainCoordinates = [ CLLocation(latitude: 39.042617, longitude: -94.587526), CLLocation(latitude: 40.774313, longitude: -73.970835), CLLocation(latitude: -33.870986, longitude: 151.211786), CLLocation(latitude: 41.875790, longitude: -87.618953), ] @State var fountains: [MKMapItem] = [] var body: some View { // SwiftUI body views } .task { var fountainMapItems = [MKMapItem]() for coordinate in fountainCoordinates { if let request = MKReverseGeocodingRequest(location: coordinate) { let mapitems = try? await request.mapItems if let mapitem = mapitems?.first { fountainMapItems.append(mapitem) } } } fountains = fountainMapItems } } ``` ``` -------------------------------- ### init(nibName:bundle:) Source: https://developer.apple.com/documentation/mapkit/mklookaroundviewcontroller/init%28coder%3A%29 Creates a new LookAround view controller from the specified nib and bundle. ```APIDOC ## init(nibName:bundle:) ### Description Creates a new LookAround view controller from the specified nib and bundle. ``` -------------------------------- ### Get and Set Map Type Source: https://developer.apple.com/documentation/mapkit/mkmapsnapshotter/options/maptype This property was used to get or set the map's visual style. It is deprecated and should be replaced with `preferredConfiguration`. ```swift var mapType: MKMapType { get set } ``` -------------------------------- ### start Method Source: https://developer.apple.com/documentation/mapkit/mkreversegeocoder/start Initiates the asynchronous reverse-geocoding process for a coordinate. ```APIDOC ## [void] [start] ### Description Starts the reverse-geocoding process asynchronously. This method should be called only once to submit the coordinate value to the map server. ### Method Instance Method ### Endpoint - (void) start; ### Discussion This method submits the coordinate value to the map server asynchronously and returns. Once the process is complete, the results are delivered to the associated delegate object. This class is deprecated; use the CLGeocoder class instead. ``` -------------------------------- ### Get highwayPreference value Source: https://developer.apple.com/documentation/mapkit/mkdirections/request/highwaypreference Use this property to get the current preference for using highways when calculating directions. This is part of the MKDirections.RoutePreference enum. ```swift var highwayPreference: MKDirections.RoutePreference { get set } ``` -------------------------------- ### Initialization with MapKit JS Source: https://developer.apple.com/documentation/mapkitjs/mapkitinitializationoptions Demonstrates how to initialize MapKit JS using the `init` method with initialization options. ```APIDOC ## Initializing MapKit JS ### Method `init(options)` ### Description Initializes MapKit JS by providing an authorization callback function and optional language and libraries. ### Parameters #### `options` (MapKitInitializationOptions) - **Required**: Yes - **Description**: An object containing initialization options. - **`language`** (string) - Optional - The preferred language for map elements. - **`authorizationCallback`** (() => Promise) - Required - A function to get the authorization token. - **`libraries`** (string[]) - Optional - An array of libraries to load. ### Request Example ```javascript // Example authorization callback const myAuthCallback = async () => { const token = await fetch('/auth/token').then(res => res.text()); return token; }; // Initialize MapKit JS with options mapkit.init({ authorizationCallback: myAuthCallback, language: 'en-US', libraries: ['drawing', 'directions'] }); ``` ### See Also - [Handling initialization events](Handling initialization events) - [Libraries](Libraries) - [loadedLibraries](loadedLibraries) - [load(libraryNames)](load(libraryNames)) ``` -------------------------------- ### start(with:completionHandler:) Source: https://developer.apple.com/documentation/mapkit/mkmapsnapshotter/start%28with%3Acompletionhandler%3A%29 Submits the request to create a snapshot and executes the resulting block on the specified queue. This method is asynchronous and delivers results to the completion handler. ```APIDOC ## func start(with:completionHandler:) ### Description Submits the request to create a snapshot and executes the resulting block on the specified queue. ### Method func ### Endpoint N/A (Instance Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None (asynchronous completion handler) #### Response Example None ### Error Handling Possible errors can be passed to the completion handler. ``` ```APIDOC ## func start(with:completionHandler:) ### Description Submits the request to create a snapshot and executes the resulting block on the specified queue. ### Method func ### Endpoint N/A (Instance Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None (asynchronous completion handler) #### Response Example None ### Error Handling Possible errors can be passed to the completion handler. ``` -------------------------------- ### Get and Set fillRule Property Source: https://developer.apple.com/documentation/mapkitjs/style/fillrule Use this property to get or set the fill rule for polygons. The default fill rule is 'nonzero'. ```typescript get fillRule(): CanvasFillRule; set fillRule(fillRule: CanvasFillRule); ``` -------------------------------- ### Get and Set Fill Color (macOS) Source: https://developer.apple.com/documentation/mapkit/mkoverlaypathrenderer/fillcolor Use this property to get or set the fill color for the path on macOS. Requires macOS 10.9+. ```swift var fillColor: NSColor? { get set } ``` -------------------------------- ### init(position:bounds:interactionModes:selection:scope:) Source: https://developer.apple.com/documentation/mapkit/map/init%28position%3Abounds%3Ainteractionmodes%3Aselection%3Ascope%3A%29 Creates a new map with the initial camera position, bounds, interaction modes, scope, and content. ```APIDOC ## init(position:bounds:interactionModes:selection:scope:) ### Description Creates a new map with the initial camera position, bounds, interaction modes, scope, and content you provide. ### Parameters - **position** (Binding) - Required - The initial MapCameraPosition. - **bounds** (MapCameraBounds?) - Optional - The MapCameraBounds that define the camera’s view of the map. - **interactionModes** (MapInteractionModes) - Optional - The MapInteractionModes that describe ways a person can interact with the map. - **selection** (Binding) - Required - A binding to a MapFeature that represents a person’s selection. - **scope** (Namespace.ID?) - Optional - The map’s Namespace.ID. ``` -------------------------------- ### Get and Set Radius in MapKit JS Source: https://developer.apple.com/documentation/mapkitjs/pointsofinterestsearch/radius Use this property to get or set the distance in meters for a search region. It can be null if not explicitly set. ```typescript get radius(): number | null; set radius(value: number | null); ``` -------------------------------- ### Method: start(completionHandler:) Source: https://developer.apple.com/documentation/mapkit/mkmapsnapshotter/start%28completionhandler%3A%29 Submits the request to create a snapshot and delivers the results to the specified block. ```APIDOC ## start(completionHandler:) ### Description Submits the request to create a snapshot and delivers the results to the specified block. This method executes the request asynchronously and delivers the final image when the app is in the foreground. ### Parameters #### Parameters - **completionHandler** (block) - Required - The block to call with the resulting snapshot. This snapshotter executes this block on the app’s main thread. ### Request Example ```swift snapshotter.start { snapshot, error in if let snapshot = snapshot { // Use the snapshot } } ``` ### Response #### Success Response - **MKMapSnapshotter.Snapshot** (object) - The resulting map snapshot image. ``` -------------------------------- ### init(scene:options:) Source: https://developer.apple.com/documentation/mapkit/mklookaroundsnapshotter/init%28scene%3Aoptions%3A%29 Initializes a new snapshotter object using a specified scene and configuration options. ```APIDOC ## init(scene:options:) ### Description Creates a new snapshotter object with the scene and options you specify. ### Parameters - **scene** (MKLookAroundScene) - Required - The MKLookAroundScene to use as the source for the snapshot. - **options** (MKLookAroundSnapshotter.Options) - Required - The available MKLookAroundSnapshotter.Options. ### Request Example init(scene: myScene, options: myOptions) ``` -------------------------------- ### Get and Set Line Width Source: https://developer.apple.com/documentation/mapkitjs/style/linewidth Use this property to get or set the width of a line's stroke in CSS pixels. The default value is 1. ```javascript get lineWidth(): number; set lineWidth(lineWidth: number); ``` -------------------------------- ### init(position:bounds:interactionModes:selection:scope:content:) Source: https://developer.apple.com/documentation/mapkit/map/init%28position%3Abounds%3Ainteractionmodes%3Aselection%3Ascope%3Acontent%3A%29-47y4p Creates a new map with the initial camera position, bounds, interaction modes, selected feature, scope, and content. ```APIDOC ## init(position:bounds:interactionModes:selection:scope:content:) ### Description Creates a new map with the initial camera position, bounds, interaction modes, selected feature, scope, and content you provide. ### Parameters - **position** (Binding) - Required - The initial MapCameraPosition. - **bounds** (MapCameraBounds?) - Optional - The MapCameraBounds that define the camera’s view of the map. - **interactionModes** (MapInteractionModes) - Optional - The MapInteractionModes that describe ways a person can interact with the map. - **selection** (Binding) - Required - A binding to a MapFeature that represents a person’s selection. - **scope** (Namespace.ID?) - Optional - The map’s Namespace.ID. - **content** (@MapContentBuilder) - Required - A MapContent content builder that supplies the map’s content. ``` -------------------------------- ### Get and Set showsPointsOfInterest Source: https://developer.apple.com/documentation/mapkitjs/map/showspointsofinterest Use this property to get or set whether the map displays points of interest. This affects standard and hybrid map modes. ```javascript get showsPointsOfInterest(): boolean; set showsPointsOfInterest(showsPointsOfInterest: boolean); ``` -------------------------------- ### Get Unwrapped Map Point from Coordinate - MapKit JS Source: https://developer.apple.com/documentation/mapkitjs/coordinate/tounwrappedmappoint Use this method to get the unwrapped map point for a coordinate. Requires MapKit JS 5.0+. ```javascript toUnwrappedMapPoint(): MapPoint; ``` -------------------------------- ### MKImageryMapConfiguration init() Source: https://developer.apple.com/documentation/mapkit/mkimagerymapconfiguration/init%28%29 Creates a new imagery based map configuration. ```APIDOC ## MKImageryMapConfiguration init() ### Description Creates a new imagery based map configuration. ### Method `init()` ### Endpoint N/A (Initializer) ### Parameters None ### Request Example ```swift let configuration = MKImageryMapConfiguration() ``` ### Response N/A (Initializer) ### See Also - `convenience init(elevationStyle: MKMapConfiguration.ElevationStyle)` ``` -------------------------------- ### init(scene:) Source: https://developer.apple.com/documentation/mapkit/mklookaroundviewcontroller/init%28coder%3A%29 Creates a new LookAround view controller with the specified scene. ```APIDOC ## init(scene:) ### Description Creates a new LookAround view controller with the specified scene. ### Parameters - **scene** (MKLookAroundScene) - Required - The scene to display in the LookAround view controller. ``` -------------------------------- ### Get and Set selectionAccessoryOffset Source: https://developer.apple.com/documentation/mapkitjs/annotation/selectionaccessoryoffset Use this property to get or set the offset for the selection accessory's anchor point. Available in MapKit JS 5.78.1 and later. ```typescript get selectionAccessoryOffset(): DOMPoint | undefined; set selectionAccessoryOffset(value: DOMPoint | undefined); ``` -------------------------------- ### Get and Set clusteringIdentifier Source: https://developer.apple.com/documentation/mapkitjs/annotation/clusteringidentifier Use this property to get or set the identifier for grouping annotations into the same cluster. Annotations with the same identifier will be clustered together. The default value is null. ```typescript get clusteringIdentifier(): string | null; set clusteringIdentifier(value: string | null); ``` -------------------------------- ### Configure CircleOverlay Options Source: https://developer.apple.com/documentation/mapkitjs/circleoverlay/circleoverlayconstructor Example object literal demonstrating how to define style, data, and enabled state for a circle overlay. ```javascript { style: new mapkit.Style({ lineWidth: 2, strokeColor: "#999", fillColor: "#FFF" }), data: { population: 30500 }, enabled: false } ``` -------------------------------- ### init(includingOptions:) Source: https://developer.apple.com/documentation/mapkit/mkaddressfilter/init%28includingoptions%3A%29 Initializes a new instance of MKAddressFilter with the specified options. This initializer is available across multiple Apple platforms and OS versions. ```APIDOC ## init(includingOptions:) ### Description Initializes a new instance of MKAddressFilter with the specified options. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Method Initializer ### Endpoint None ### Request Example None ### Response #### Success Response An initialized `MKAddressFilter` object. #### Response Example None ``` -------------------------------- ### Get and Set Overlay Visibility Source: https://developer.apple.com/documentation/mapkitjs/overlay/visible Use the `visible` property to get or set the visibility of an overlay. Set to `false` to hide, `true` to show. The default value is `true`. ```typescript get visible(): boolean; set visible(visible: boolean); ``` -------------------------------- ### MKMapItem Initializers Source: https://developer.apple.com/documentation/mapkit/mkmapitem/mkmapitem-implementations Documentation for initializing an MKMapItem from a coder object. ```APIDOC ## init?(coder: NSCoder) ### Description Initializes an MKMapItem object from data in a given unarchiver. ### Parameters #### Parameters - **coder** (NSCoder) - Required - The unarchiver object. ``` -------------------------------- ### Get and Set showsCompass Property Source: https://developer.apple.com/documentation/mapkitjs/map/showscompass Use this property to get the current visibility state of the compass or to set its visibility. The compass is adaptive by default, appearing only when the map is rotated. ```typescript get showsCompass(): FeatureVisibility; set showsCompass(value: FeatureVisibility); ``` -------------------------------- ### Get and Set Map Type in MapKit JS Source: https://developer.apple.com/documentation/mapkitjs/map/maptype Use this property to get or set the current map display type. The map type is defined by the `MapType` enum. ```typescript get mapType(): MapType; set mapType(mapType: MapType); ``` -------------------------------- ### init(location:address:) Source: https://developer.apple.com/documentation/mapkit/mkmapitem/init%28location%3Aaddress%3A%29 Initializes a new MKMapItem object using a specified location and address. ```APIDOC ## init(location:address:) ### Description Creates and returns a map item object using the specified location and address objects. ### Parameters - **location** (CLLocation) - Required - A CLLocation object representing the geographic coordinates. - **address** (MKAddress?) - Optional - An MKAddress object representing the address details. ### Return Value - **MKMapItem** - An initialized map item object. ### Discussion Use this method to create a map item for a specific location. Do not use it to create a map item representing the current location of someone’s device; instead, use the MKMapItem.forCurrentLocation() method. ``` -------------------------------- ### Get and Set Map Center Coordinate Source: https://developer.apple.com/documentation/mapkit/mkmapcamera/centercoordinate Use this property to get or set the CLLocationCoordinate2D that represents the center of the map view. This is useful for programmatically controlling the map's focus. ```swift var centerCoordinate: CLLocationCoordinate2D { get set } ``` -------------------------------- ### init(position:bounds:interactionModes:scope:) Source: https://developer.apple.com/documentation/mapkit/map/init%28position%3Abounds%3Ainteractionmodes%3Ascope%3A%29 Creates a new, empty map with the initial camera position, bounds, interaction modes, and scope you provide. ```APIDOC ## init(position:bounds:interactionModes:scope:) ### Description Creates a new, empty map with the initial camera position, bounds, interaction modes, and scope you provide. ### Parameters - **position** (Binding) - Required - The initial MapCameraPosition. - **bounds** (MapCameraBounds?) - Optional - The MapCameraBounds that define the camera’s view of the map. - **interactionModes** (MapInteractionModes) - Optional - The MapInteractionModes that describe ways a person can interact with the map. - **scope** (Namespace.ID?) - Optional - The map’s Namespace.ID. ### Request Example ```swift @MainActor @preconcurrency init( position: Binding, bounds: MapCameraBounds? = nil, interactionModes: MapInteractionModes = .all, scope: Namespace.ID? = nil ) where Content == MapContentView ``` ``` -------------------------------- ### Get and Set annotationForCluster Delegate Source: https://developer.apple.com/documentation/mapkitjs/map/annotationforcluster This code shows how to get and set the annotationForCluster delegate method. This delegate method is invoked when MapKit JS creates or updates a cluster annotation. ```typescript get annotationForCluster(): | ((clusterAnnotation: ClusterAnnotation) => Annotation | undefined) | null; set annotationForCluster( value: | ((clusterAnnotation: ClusterAnnotation) => Annotation | undefined) | null, ); ``` -------------------------------- ### init(_:) Source: https://developer.apple.com/documentation/mapkit/mkfeaturedisplaypriority/init%28_%3A%29 Initializes a new MKFeatureDisplayPriority instance with a specified floating point value. ```APIDOC ## init(_:) ### Description Creates a feature display priority using the specified floating point value. ### Parameters #### Parameters - **rawValue** (Float) - Required - The floating point value of the feature display priority. ### Request Example init(0.5) ``` -------------------------------- ### Get and Set Fill Color (iOS) Source: https://developer.apple.com/documentation/mapkit/mkoverlaypathrenderer/fillcolor Use this property to get or set the fill color for the path on iOS, iPadOS, Mac Catalyst, tvOS, and visionOS. Requires iOS 7.0+. ```swift var fillColor: UIColor? { get set } ``` -------------------------------- ### Initialize TileOverlay with URL Template and Options Source: https://developer.apple.com/documentation/mapkitjs/tileoverlay/tileoverlayconstructor Use this constructor to create a tile overlay. Provide a URL template for fetching tiles and optional configuration settings. ```typescript constructor( urlTemplate: TileOverlayUrlTemplate, options?: TileOverlayConstructorOptions, ); ``` -------------------------------- ### Creating a Map with Initial Position, Bounds, Interaction Modes, Selection, Scope, and Content (Generic) Source: https://developer.apple.com/documentation/mapkit/map/init%28bounds%3Ainteractionmodes%3Aselection%3Ascope%3Acontent%3A%29-2tdbr Initializes a new map with the initial camera position, bounds, interaction modes, selected map feature, scope, and content. ```APIDOC ## Initializer: init(initialPosition:bounds:interactionModes:selection:scope:content:) ### Description Creates a new map with the initial camera position, bounds, interaction modes, selected map feature, scope, and content you provide. ### Method `init` ### Endpoint N/A (Initializer) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) Map object #### Response Example None ``` -------------------------------- ### Get boundingRegion of MKLocalSearch.Response Source: https://developer.apple.com/documentation/mapkit/mklocalsearch/response/boundingregion Access the boundingRegion property to get the smallest map region that encloses all search results. If only one result exists, the region size might be (0, 0). ```swift var boundingRegion: MKCoordinateRegion { get } ``` -------------------------------- ### Get and Set MarkerAnnotation Color Source: https://developer.apple.com/documentation/mapkitjs/markerannotation/color Use this property to get or set the background color of the annotation balloon. It accepts color names or hexadecimal values. The default value is a shade of red. ```typescript get color(): string; set color(value: string); ``` -------------------------------- ### Implementing MapPitchToggle Source: https://developer.apple.com/documentation/mapkit/mappitchtoggle Examples demonstrating how to integrate the pitch toggle control into a map view. ```swift struct MyMapView: View { @Namespace var mapScope var body: some View { VStack { Map(scope: mapScope) MapPitchToggle(scope: mapScope) } .mapScope(mapScope) } } ``` ```swift Map() .mapControls { MapPitchToggle() } ``` -------------------------------- ### PolygonOverlay Options Configuration Source: https://developer.apple.com/documentation/mapkitjs/polygonoverlay/polygonoverlayconstructor Example object literal demonstrating style and state configuration for a polygon overlay. ```javascript { style: new mapkit.Style({ lineWidth: 2, strokeColor: "#F00", fillColor: "#339" }), selected: true } ``` -------------------------------- ### Get and Set showsZoomControl Property Source: https://developer.apple.com/documentation/mapkitjs/map/showszoomcontrol Use this property to get or set a Boolean value that determines whether to display a control for zooming in and zooming out on a map. Available in MapKit JS 5.0+. ```javascript get showsZoomControl(): boolean; set showsZoomControl(showsZoomControl: boolean); ``` -------------------------------- ### Initializer: init(coordinate:) Source: https://developer.apple.com/documentation/mapkit/mklookaroundscenerequest/init%28coordinate%3A%29 Creates a LookAround scene at the specified coordinates. ```APIDOC ## init(coordinate:) ### Description Creates a Look Around scene at the specified coordinates. ### Method Initializer ### Endpoint N/A (Initializer) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```swift init(coordinate: CLLocationCoordinate2D) ``` ### Response #### Success Response (200) N/A (Initializer) #### Response Example N/A (Initializer) ## Parameters `coordinate` A `CLLocationCoordinate2D` coordinate that indicates the location for the LookAround scene. ``` -------------------------------- ### Get and Set Selected Overlay in MapKit JS Source: https://developer.apple.com/documentation/mapkitjs/map/selectedoverlay Use this property to get the currently selected overlay or set a new overlay to be selected. To deselect any overlay, set this property to `null`. ```javascript get selectedOverlay(): Overlay | null; set selectedOverlay(overlay: Overlay | null); ``` -------------------------------- ### Get and Set Map Padding Source: https://developer.apple.com/documentation/mapkitjs/map/padding Use this property to get the current padding or set a new padding for the map. The padding affects the map's controls layout and the visible region. ```typescript get padding(): Padding; set padding(padding: Padding); ``` -------------------------------- ### init(elevationStyle:emphasisStyle:) Source: https://developer.apple.com/documentation/mapkit/mkstandardmapconfiguration/init%28elevationstyle%3Aemphasisstyle%3A%29 Creates a standard map configuration with the specified elevation and emphasis styles. ```APIDOC ## init(elevationStyle:emphasisStyle:) ### Description Creates a standard map configuration with the specified elevation and emphasis styles. ### Parameters #### Parameters - **elevationStyle** (MKMapConfiguration.ElevationStyle) - Required - One of the MKMapConfiguration.ElevationStyle modes. - **emphasisStyle** (MKStandardMapConfiguration.EmphasisStyle) - Required - One of the MKStandardMapConfiguration.EmphasisStyle styles. ### Request Example convenience init( elevationStyle: MKMapConfiguration.ElevationStyle, emphasisStyle: MKStandardMapConfiguration.EmphasisStyle ) ``` -------------------------------- ### MKStandardMapConfiguration init() Source: https://developer.apple.com/documentation/mapkit/mkstandardmapconfiguration/init%28%29 Creates a new standard map configuration. ```APIDOC ## init() ### Description Creates a new standard map configuration. ### Method init() ### Endpoint N/A (Initializer) ### Parameters None ### Request Example ```swift let mapConfiguration = MKStandardMapConfiguration() ``` ### Response N/A (Initializer returns an instance) ### See Also - `convenience init(elevationStyle: MKMapConfiguration.ElevationStyle)` - `convenience init(elevationStyle: MKMapConfiguration.ElevationStyle, emphasisStyle: MKStandardMapConfiguration.EmphasisStyle)` - `convenience init(emphasisStyle: MKStandardMapConfiguration.EmphasisStyle)` ``` -------------------------------- ### Get and Set showsDialogControl Source: https://developer.apple.com/documentation/mapkitjs/lookaround/showsdialogcontrol Use this property to get or set a boolean value indicating whether the Look Around view displays a control to expand it. Available in MapKit JS 5.79+. ```javascript get showsDialogControl(): boolean; set showsDialogControl(value: boolean); ``` -------------------------------- ### MapKit Initializer: init(centerCoordinate:distance:heading:pitch:) Source: https://developer.apple.com/documentation/mapkit/mapcamera/init%28centercoordinate%3Adistance%3Aheading%3Apitch%3A%29 Creates a camera using the specified distance, pitch, and heading information. ```APIDOC ## Initializer: init(centerCoordinate:distance:heading:pitch:) ### Description Creates a camera using the specified distance, pitch, and heading information. ### Method Initializer ### Endpoint N/A (Swift Initializer) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```swift init( centerCoordinate: CLLocationCoordinate2D, distance: Double, heading: Double = 0, pitch: Double = 0 ) ``` ### Response #### Success Response (200) N/A (Initializer) #### Response Example None ``` -------------------------------- ### Get and Set showsRoadLabels Source: https://developer.apple.com/documentation/mapkitjs/abstractlookaround/showsroadlabels Use this property to get or set a boolean value indicating whether road labels are displayed in the Look Around view. Requires MapKit JS 5.79+. ```typescript get showsRoadLabels(): boolean; set showsRoadLabels(value: boolean); ``` -------------------------------- ### Creating a Polygon Overlay with Cutouts Source: https://developer.apple.com/documentation/mapkitjs/polygonoverlay/points Example demonstrating how to create a complex polygon overlay with cutouts using multiple coordinate arrays and the `evenodd` fill rule. ```APIDOC ## Example: Creating a Polygon Overlay with Cutouts ### Description This example illustrates the creation of a rectangle polygon overlay with two triangular cutouts, utilizing the `evenodd` fill rule for defining the interior of the complex shape. ### Method `new mapkit.PolygonOverlay()` ### Endpoint N/A (Client-side JavaScript) ### Parameters None directly for this example, but it utilizes `mapkit.Coordinate` and `mapkit.Style`. ### Request Example ```javascript // Helper function to convert simple arrays to mapkit.Coordinate objects function toCoordinates(array) { return array.map(function(element) { return new mapkit.Coordinate(element[0], element[1]); }); } // Define the points for the outer rectangle and inner triangles const rectangle = [ [0, 0], [20, 0], [20, 10], [0, 10] ]; const triangle1 = [ [4, 4], [8, 4], [6, 6] ]; const triangle2 = [ [14, 4], [18, 4], [16, 6] ]; // Combine points into the format required by PolygonOverlay const points = [ toCoordinates(rectangle), toCoordinates(triangle1), toCoordinates(triangle2) ]; // Define the style, including the fillRule for complex polygons const style = new mapkit.Style({ strokeColor: "#777", fillRule: "evenodd" }); // Create the PolygonOverlay instance const overlay = new mapkit.PolygonOverlay(points, { style: style }); // To add the overlay to the map, you would typically use: // map.addOverlay(overlay); ``` ### Response N/A (This is a client-side code example for creating an overlay.) ``` -------------------------------- ### Example: Convert MapRect to CoordinateRegion and back Source: https://developer.apple.com/documentation/mapkitjs/maprect/tocoordinateregion This example shows how to create a `MapRect`, convert it to a `CoordinateRegion`, and then convert that region back to a `MapRect`. Note that floating-point inaccuracies may occur during the round trip. ```javascript const mapRect = new mapkit.MapRect(0.1, 0.2, 0.3, 0.4); // Return a coordinate region with center (33.841220320476786, -90) and span (106.57400641480324, 108). const coordinateRegion = mapRect.toCoordinateRegion(); // Return the same map rectangle as mapRect, plus or minus any floating point inaccuracies. const newMapRect = coordinateRegion.toMapRect(); ``` -------------------------------- ### Example URL Template Source: https://developer.apple.com/documentation/mapkit/mktileoverlay/init%28urltemplate%3A%29-9s8h7 Specifies a template string for requesting tiles from a server. The placeholders {x}, {y}, {z}, and {scale} are substituted with actual values. ```string http://myserver/tile?x={x}&y={y}&z={z}&scale={scale} ``` -------------------------------- ### Get and Set Badge Position - MKLookAroundViewController Source: https://developer.apple.com/documentation/mapkit/mklookaroundviewcontroller/badgeposition Use this property to get or set the position of the badge on the LookAround view. Requires iOS 16.0+, iPadOS 16.0+, macOS 13.0+, or visionOS 1.0+. ```swift var badgePosition: MKLookAroundBadgePosition { get set } ``` -------------------------------- ### Get and Set showsScale Property in MapKit JS Source: https://developer.apple.com/documentation/mapkitjs/map/showsscale Use this property to get or set the visibility of the map's scale indicator. MapKit JS ignores invalid values and reports them to the console. ```javascript get showsScale(): FeatureVisibility; set showsScale(showsScale: FeatureVisibility); ``` -------------------------------- ### Map Creation Initializers Source: https://developer.apple.com/documentation/mapkit/map/init%28position%3Abounds%3Ainteractionmodes%3Aselection%3Ascope%3Acontent%3A%29-9xq1q This section provides examples of how to initialize a MapKit map with different parameters. ```APIDOC ## Map Creation ### Description Provides various initializers for creating a MapKit map with customizable options. ### Initializers #### `init(bounds: MapCameraBounds?, interactionModes: MapInteractionModes, scope: Namespace.ID?)` Creates a new, empty map with the specified bounds, interaction modes, and scope. #### `init(bounds: MapCameraBounds?, interactionModes: MapInteractionModes, scope: Namespace.ID?, content: () -> C)` Creates a new map with the specified bounds, interaction modes, scope, and custom content. #### `init(bounds: MapCameraBounds?, interactionModes: MapInteractionModes, selection: Binding, scope: Namespace.ID?)` Creates a new, empty map with the specified bounds, interaction modes, a binding to a map feature, and scope. #### `init(bounds: MapCameraBounds?, interactionModes: MapInteractionModes, selection: Binding, scope: Namespace.ID?)` Creates a new, empty map with the specified bounds, interaction modes, the selected map feature, and scope. #### `init(bounds: MapCameraBounds?, interactionModes: MapInteractionModes, selection: Binding, scope: Namespace.ID?, content: () -> C)` Creates a new map with the specified bounds, interaction modes, selected map feature, scope, and custom content. #### `init(bounds: MapCameraBounds?, interactionModes: MapInteractionModes, selection: Binding, scope: Namespace.ID?, content: () -> C)` Creates a new map with the specified bounds, interaction modes, selected value, scope, and map content. #### `init(initialPosition: MapCameraPosition, bounds: MapCameraBounds?, interactionModes: MapInteractionModes, scope: Namespace.ID?)` Creates a new, empty map with the initial camera position, bounds, interaction modes, and scope. #### `init(initialPosition: MapCameraPosition, bounds: MapCameraBounds?, interactionModes: MapInteractionModes, scope: Namespace.ID?, content: () -> C)` Creates a new map with the initial camera position, bounds, interaction modes, scope, and custom content. #### `init(initialPosition: MapCameraPosition, bounds: MapCameraBounds?, interactionModes: MapInteractionModes, selection: Binding, scope: Namespace.ID?)` Creates a new, empty map with the initial camera position, bounds, interaction modes, selected map feature, and scope. #### `init(initialPosition: MapCameraPosition, bounds: MapCameraBounds?, interactionModes: MapInteractionModes, selection: Binding, scope: Namespace.ID?, content: () -> C)` Creates a new map with the initial camera position, bounds, interaction modes, selected map feature, scope, and content. #### `init(initialPosition: MapCameraPosition, bounds: MapCameraBounds?, interactionModes: MapInteractionModes, selection: Binding, scope: Namespace.ID?, content: () -> C)` Creates a new map with the initial camera position, bounds, interaction modes, selected map feature, scope, and content. #### `init(position: Binding, bounds: MapCameraBounds?, interactionModes: MapInteractionModes, scope: Namespace.ID?)` Creates a new, empty map with the initial camera position, bounds, interaction modes, and scope. #### `init(position: Binding, bounds: MapCameraBounds?, interactionModes: MapInteractionModes, scope: Namespace.ID?, content: () -> C)` Creates a new map with the initial camera position, bounds, interaction modes, scope, and content. #### `init(position: Binding, bounds: MapCameraBounds?, interactionModes: MapInteractionModes, selection: Binding, scope: Namespace.ID?)` Creates a new map with the initial camera position, bounds, interaction modes, scope, and content. #### `init(position: Binding, bounds: MapCameraBounds?, interactionModes: MapInteractionModes, selection: Binding, scope: Namespace.ID?, content: () -> C)` Creates a new map with the initial camera position, bounds, interaction modes, selected feature, scope, and content. ``` -------------------------------- ### init(request:) Source: https://developer.apple.com/documentation/mapkit/mklocalsearch/init%28request%3A%29-12tf0 Initializes a search object with the specified MKLocalSearch.Request parameters. ```APIDOC ## init(request:) ### Description Creates and returns a search object with the specified parameters. This method stores a copy of the object in the request parameter, meaning it ignores any subsequent changes made to the request object. ### Parameters #### Path Parameters - **request** (MKLocalSearch.Request) - Required - The search request information. ``` -------------------------------- ### Get and Set urlTemplate in TileOverlay Source: https://developer.apple.com/documentation/mapkitjs/tileoverlay/urltemplate Use this property to get or set the URL template for a tile overlay. MapKit JS uses this URL to fetch map tiles. Available in MapKit JS 5.0+. ```typescript get urlTemplate(): TileOverlayUrlTemplate; set urlTemplate(urlTemplate: TileOverlayUrlTemplate); ``` -------------------------------- ### Get and Set strokeEnd Property Source: https://developer.apple.com/documentation/mapkitjs/style/strokeend Use this property to get or set the unit distance along the line where a stroke ends. The value must be between 0 and 1. The stroke is only visible when strokeStart is less than strokeEnd. ```javascript get strokeEnd(): number; set strokeEnd(strokeEnd: number); ``` -------------------------------- ### Creating a Map with Position Binding, Bounds, Interaction Modes, Selection, Scope, and Content (Generic) Source: https://developer.apple.com/documentation/mapkit/map/init%28bounds%3Ainteractionmodes%3Aselection%3Ascope%3Acontent%3A%29-2tdbr Initializes a new map with the initial camera position binding, bounds, interaction modes, selected feature, scope, and content. ```APIDOC ## Initializer: init(position:bounds:interactionModes:selection:scope:content:) ### Description Creates a new map with the initial camera position, bounds, interaction modes, selected feature, scope, and content you provide. ### Method `init` ### Endpoint N/A (Initializer) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) Map object #### Response Example None ``` -------------------------------- ### Get and Set Region in MapKit JS Source: https://developer.apple.com/documentation/mapkitjs/pointsofinterestsearch/region Use the `region` property to get or set the `CoordinateRegion` that bounds the area for fetching points of interest. This property is available in MapKit JS version 5.45 and later. ```javascript get region(): CoordinateRegion | null; set region(value: CoordinateRegion | null); ``` -------------------------------- ### Initializer: init(_:) Source: https://developer.apple.com/documentation/mapkit/mapcamera/init%28_%3A%29 Creates a map camera from the given MapKit camera object. ```APIDOC ## Initializer: init(_:) ### Description Creates a map camera from the given MapKit camera object. ### Method Initializer ### Endpoint N/A (Initializer) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### init() Source: https://developer.apple.com/documentation/mapkit/mklocalsearch/request/init%28%29 Initializes a new local search request object. ```APIDOC ## init() ### Description Creates a local search request. ### Method Initializer ### Request Example let request = MKLocalSearch.Request() ``` -------------------------------- ### Get and Set cameraDistance in MapKit JS Source: https://developer.apple.com/documentation/mapkitjs/map/cameradistance Use this property to get or set the camera's altitude in meters relative to the map's center elevation. The value must be greater than or equal to 0. ```javascript get cameraDistance(): number; set cameraDistance(value: number); ``` -------------------------------- ### Creating a Map with Initial Position, Bounds, Interaction Modes, Scope, and Content Source: https://developer.apple.com/documentation/mapkit/map/init%28bounds%3Ainteractionmodes%3Aselection%3Ascope%3Acontent%3A%29-2tdbr Initializes a new map with the initial camera position, bounds, interaction modes, scope, and custom content. ```APIDOC ## Initializer: init(initialPosition:bounds:interactionModes:scope:content:) ### Description Creates a new map with the initial camera position, bounds, interaction modes, scope, and map content you provide. ### Method `init` ### Endpoint N/A (Initializer) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) Map object #### Response Example None ``` -------------------------------- ### Get and Set Camera Boundary Source: https://developer.apple.com/documentation/mapkitjs/map/cameraboundary Use this property to get the current camera boundary or set a new one using CoordinateRegion or MapRect. Setting the property requires either a CoordinateRegion or a MapRect instance. ```typescript get cameraBoundary(): CameraBoundaryDescription | null; set cameraBoundary(cameraBoundary: null | CoordinateRegion | MapRect); ``` -------------------------------- ### init(completion:) Source: https://developer.apple.com/documentation/mapkit/mklocalsearch/request/init%28%29 Initializes a search request based on existing completion data. ```APIDOC ## init(completion: MKLocalSearchCompletion) ### Description Creates and returns a search request based on the specified search completion data. ### Parameters #### Path Parameters - **completion** (MKLocalSearchCompletion) - Required - The search completion data to use for the request. ``` -------------------------------- ### Get and Set pointOfInterestFilter Source: https://developer.apple.com/documentation/mapkit/mkhybridmapconfiguration/pointofinterestfilter Use this property to get or set the filter that determines which points of interest are shown on the map. Available on iOS 16.0+, iPadOS 16.0+, macOS 13.0+, tvOS 16.0+, and visionOS 1.0+. ```swift @NSCopying var pointOfInterestFilter: MKPointOfInterestFilter? { get set } ``` -------------------------------- ### Get and Set strokeOpacity in MapKit JS Source: https://developer.apple.com/documentation/mapkitjs/style/strokeopacity Use this property to get or set the opacity of a stroke color for overlays. The value ranges from 0 (fully transparent) to 1 (fully opaque). The default value is 1. ```typescript get strokeOpacity(): number; set strokeOpacity(strokeOpacity: number); ``` -------------------------------- ### Example: Setting the Coordinate Property Source: https://developer.apple.com/documentation/mapkitjs/search/coordinate Instantiate a new Coordinate object with latitude and longitude, then assign it to the coordinate property to set the search hint. ```javascript { coordinate: new mapkit.Coordinate(37.779268, -122.419248) } ```