UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

107 lines (105 loc) 5.14 kB
import type Graphic from "../../Graphic.js"; import type PopupTemplate from "../../PopupTemplate.js"; import type Point from "../../geometry/Point.js"; import type { ClonableMixin } from "../../core/Clonable.js"; import type { JSONSupport } from "../../core/JSONSupport.js"; import type { DirectionPointType } from "./types.js"; import type { PointProperties } from "../../geometry/Point.js"; import type { PopupTemplateProperties } from "../../PopupTemplate.js"; export interface DirectionPointProperties extends Partial<Pick<DirectionPoint, "arrivalTimeOffset" | "directionPointType" | "displayText" | "sequence">> { /** Time when the action happens. */ arrivalTime?: (Date | number | string) | null; /** Point representing the direction's location. */ geometry?: PointProperties | null; /** * The template for displaying content in a [Popup](https://developers.arcgis.com/javascript/latest/references/core/widgets/Popup/) when the graphic is selected. * * @since 4.30 */ popupTemplate?: PopupTemplateProperties | null; } /** * The DirectionPoint represents direction items as points with various display information. * * @since 4.23 * @see [RouteLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/RouteLayer/) * @see [RouteParameters](https://developers.arcgis.com/javascript/latest/references/core/rest/support/RouteParameters/) * @see [Routing Services | Direct request | Output parameters | directionPoints](https://developers.arcgis.com/rest/services-reference/enterprise/route-sync-services/#directionpoints) * @example * // Print driving directions. * const routeLayer = new RouteLayer({ * portalItem: { * id: "69569b47b1e445b8a42ec12feab41ce9" * } * }); * await routeLayer.load(); * * const locale = "en-US"; * const formatDate = new Intl.DateTimeFormat(locale, { * year: 'numeric', * month: 'numeric', * day: 'numeric', * hour: 'numeric', * minute: 'numeric', * second: 'numeric', * timeZone: "America/Los_Angeles" * }); * * for (const directionPoint of routeLayer.directionPoints) { * const { arrivalTime, displayText } = directionPoint; * console.log(`${formatDate.format(arrivalTime)}: ${displayText}`); * } * * // Output * // 12/7/2020, 3:58:50 PM: Start at Kenoak Pl, Pomona, California, 91768 * // 12/7/2020, 3:58:50 PM: Go northeast on Kenoak Pl toward Preciado St * // 12/7/2020, 3:59:15 PM: Turn left on Preciado St * // 12/7/2020, 3:59:26 PM: Turn left on N White Ave * // 12/7/2020, 3:59:37 PM: Turn right onto the ramp and go on I-10 W * // 12/7/2020, 4:02:10 PM: Take the ramp on the right to CA-57 S / CA-57 N toward Santa Ana / I-210 * // 12/7/2020, 4:02:24 PM: Keep right at the fork onto CA-57 N toward I-210 * // 12/7/2020, 4:06:54 PM: Take the ramp on the right at exit 25B and go on CA-210 E toward San Bernardino */ export default class DirectionPoint extends DirectionPointSuperclass { /** * Creates a [DirectionPoint](https://developers.arcgis.com/javascript/latest/references/core/rest/support/DirectionPoint/) from the parsed [Graphic](https://developers.arcgis.com/javascript/latest/references/core/Graphic/). * The method assumes that the graphic's attributes conform to the route layer item schema. * * @param graphic - A Graphic instance. * @returns A DirectionPoint instance. * @since 4.24 */ static fromGraphic(graphic: Graphic): DirectionPoint; constructor(properties?: DirectionPointProperties); /** Time when the action happens. */ get arrivalTime(): Date | null | undefined; set arrivalTime(value: (Date | number | string) | null | undefined); /** The local time offset (in minutes) for the arrival time. */ accessor arrivalTimeOffset: number | null | undefined; /** The type of directions event or maneuver described by the point. */ accessor directionPointType: DirectionPointType | null | undefined; /** The direction item text to dispay on the screen. */ accessor displayText: string | null | undefined; /** Point representing the direction's location. */ get geometry(): Point | null | undefined; set geometry(value: PointProperties | null | undefined); /** * The template for displaying content in a [Popup](https://developers.arcgis.com/javascript/latest/references/core/widgets/Popup/) when the graphic is selected. * * @since 4.30 */ get popupTemplate(): PopupTemplate | null | undefined; set popupTemplate(value: PopupTemplateProperties | null | undefined); /** Sequence of the Direction items, starting with 1. */ accessor sequence: number | null | undefined; get type(): "direction-point"; /** * Creates a [Graphic](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) from the [DirectionPoint](https://developers.arcgis.com/javascript/latest/references/core/rest/support/DirectionPoint/) instance. * The resulting graphic will have attributes that conform to the route layer item schema. * * @returns A Graphic instance. * @since 4.24 */ toGraphic(): Graphic; } declare const DirectionPointSuperclass: typeof JSONSupport & typeof ClonableMixin