|
| 1 | +// Type definitions for MapKit JS 5.0 |
| 2 | +// Project: https://developer.apple.com/documentation/mapkitjs |
| 3 | +// Definitions by: Waseem Dahman <https://github.com/wsmd> |
| 4 | + |
| 5 | +declare namespace mapkit { |
| 6 | + /** |
| 7 | + * Creates a directions object with options that you may provide. |
| 8 | + */ |
| 9 | + class Directions { |
| 10 | + /** |
| 11 | + * Creates a directions object with options that you may provide. |
| 12 | + * |
| 13 | + * @param An object containing the options for creating a directions object. |
| 14 | + * This parameter is optional. |
| 15 | + */ |
| 16 | + constructor(options?: Partial<DirectionsConstructorOptions>); |
| 17 | + /** |
| 18 | + * Retrieves directions and estimated travel time for the specified start |
| 19 | + * and end points. |
| 20 | + * |
| 21 | + * @param request DirectionsRequest object that specifies details for the |
| 22 | + * directions you want to retrieve. |
| 23 | + * @param callback A callback function that receives the directions, |
| 24 | + * returned asynchronously. |
| 25 | + * @return A request ID, which you can pass to cancel to abort a pending request. |
| 26 | + */ |
| 27 | + route( |
| 28 | + request: DirectionsRequest, |
| 29 | + callback: (error: Error | null, data: DirectionsResponse) => void, |
| 30 | + ): number; |
| 31 | + /** |
| 32 | + * Cancels a previous request for route directions. |
| 33 | + */ |
| 34 | + // cancel(); |
| 35 | + /** |
| 36 | + * The modes of transportation. |
| 37 | + */ |
| 38 | + static readonly Transport: TransportType; |
| 39 | + } |
| 40 | + |
| 41 | + /** |
| 42 | + * Options that you may provide when creating a directions object. |
| 43 | + */ |
| 44 | + interface DirectionsConstructorOptions { |
| 45 | + /** |
| 46 | + * A language ID that determines the language for route information. |
| 47 | + */ |
| 48 | + language: string; |
| 49 | + } |
| 50 | + |
| 51 | + /** |
| 52 | + * The modes of transportation. |
| 53 | + */ |
| 54 | + interface TransportType { |
| 55 | + /** |
| 56 | + * A constant identifying the mode of transportation as driving. |
| 57 | + */ |
| 58 | + readonly Automobile: string; |
| 59 | + /** |
| 60 | + * A constant identifying the mode of transportation as walking. |
| 61 | + */ |
| 62 | + readonly Walking: string; |
| 63 | + } |
| 64 | + |
| 65 | + /** |
| 66 | + * The requested start and end points for a route, as well as the planned mode of transportation. |
| 67 | + */ |
| 68 | + interface DirectionsRequest { |
| 69 | + /** |
| 70 | + * The start point for routing directions. |
| 71 | + */ |
| 72 | + origin: String | mapkit.Coordinate | mapkit.Place; |
| 73 | + /** |
| 74 | + * The end point for routing directions. |
| 75 | + */ |
| 76 | + destination: String | mapkit.Coordinate | mapkit.Place; |
| 77 | + /** |
| 78 | + * The mode of transportation to which directions should apply. |
| 79 | + */ |
| 80 | + transportType?: TransportType[keyof TransportType]; |
| 81 | + /** |
| 82 | + * A Boolean value that indicates whether the server should return multiple |
| 83 | + * routes when they are available. |
| 84 | + */ |
| 85 | + requestsAlternateRoutes?: boolean; |
| 86 | + } |
| 87 | + |
| 88 | + /** |
| 89 | + * The directions and estimated travel time returned for a route. |
| 90 | + */ |
| 91 | + interface DirectionsResponse { |
| 92 | + request: any; |
| 93 | + routes: Route[]; |
| 94 | + } |
| 95 | + |
| 96 | + /** |
| 97 | + * Information about a route, including step-by-step instructions, distance, and estimated travel time. |
| 98 | + */ |
| 99 | + interface Route { |
| 100 | + /** |
| 101 | + * An instance of a polyline overlay that represents the path of a route. |
| 102 | + */ |
| 103 | + polyline: mapkit.PolylineOverlay; |
| 104 | + /** |
| 105 | + * An array of coordinate objects representing the path of the route. |
| 106 | + * @deprecated |
| 107 | + */ |
| 108 | + path: mapkit.Coordinate[]; |
| 109 | + /** |
| 110 | + * An array of steps that comprise the overall route. |
| 111 | + */ |
| 112 | + steps: RouteStep[]; |
| 113 | + /** |
| 114 | + * The name assigned to the route. |
| 115 | + */ |
| 116 | + name: string; |
| 117 | + /** |
| 118 | + * The route distance in meters. |
| 119 | + */ |
| 120 | + distance: number; |
| 121 | + /** |
| 122 | + * The expected travel time in seconds. |
| 123 | + */ |
| 124 | + expectedTravelTime: number; |
| 125 | + /** |
| 126 | + * The overall route transport type. |
| 127 | + */ |
| 128 | + transportType: TransportType[keyof TransportType]; |
| 129 | + } |
| 130 | + |
| 131 | + /** |
| 132 | + * A single route between a requested start and end point. |
| 133 | + */ |
| 134 | + interface RouteStep { |
| 135 | + /** |
| 136 | + * An array of coordinate objects representing the path of the route segment. |
| 137 | + */ |
| 138 | + path: mapkit.Coordinate[]; |
| 139 | + /** |
| 140 | + * The written instructions for following the path represented by the step. |
| 141 | + */ |
| 142 | + instructions: String; |
| 143 | + /** |
| 144 | + * The step distance in meters. |
| 145 | + */ |
| 146 | + distance: Number; |
| 147 | + /** |
| 148 | + * The transport type of the step. |
| 149 | + */ |
| 150 | + transportType: TransportType[keyof TransportType]; |
| 151 | + } |
| 152 | +} |
0 commit comments