@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
97 lines (95 loc) • 4.33 kB
TypeScript
import type Graphic from "../../Graphic.js";
import type PopupTemplate from "../../PopupTemplate.js";
import type Polyline from "../../geometry/Polyline.js";
import type { ClonableMixin } from "../../core/Clonable.js";
import type { JSONSupport } from "../../core/JSONSupport.js";
import type { DirectionLineType } from "./types.js";
import type { PolylineProperties } from "../../geometry/Polyline.js";
import type { PopupTemplateProperties } from "../../PopupTemplate.js";
export interface DirectionLineProperties extends Partial<Pick<DirectionLine, "directionLineType" | "distance" | "duration">> {
/** Polyline representing the direction's location. */
geometry?: PolylineProperties | 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 DirectionLine represents polylines associated with individual direction items.
*
* @since 4.23
* @see [RouteParameters](https://developers.arcgis.com/javascript/latest/references/core/rest/support/RouteParameters/)
* @see [RouteLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/RouteLayer/)
* @example
* // Print the distance and time between each direction.
* const routeLayer = new RouteLayer({
* portalItem: {
* id: "69569b47b1e445b8a42ec12feab41ce9"
* }
* });
* await routeLayer.load();
*
* const locale = "en-US";
* const formatMinutes = new Intl.NumberFormat(locale, {
* minimumFractionDigits: 1,
* maximumFractionDigits: 1
* });
* const formatDistance = new Intl.NumberFormat(locale, {
* minimumFractionDigits: 0,
* maximumFractionDigits: 0
* });
*
* for (const directionLine of routeLayer.directionLines) {
* const { distance, duration } = directionLine;
* console.log(`Drive ${formatDistance.format(distance)} meters for ${formatMinutes.format(duration)} minutes.`);
* }
*
* // Drive 76 meters for 0.4 minutes.
* // Drive 77 meters for 0.2 minutes.
* // Drive 150 meters for 0.2 minutes.
* // Drive 3,670 meters for 2.6 minutes.
* // Drive 307 meters for 0.2 minutes.
* // Drive 6,293 meters for 4.5 minutes.
* // Drive 42,276 meters for 29.2 minutes.
* // etc.
*/
export default class DirectionLine extends DirectionLineSuperclass {
/**
* Creates a [DirectionLine](https://developers.arcgis.com/javascript/latest/references/core/rest/support/DirectionLine/) 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 DirectionLine instance.
* @since 4.24
*/
static fromGraphic(graphic: Graphic): DirectionLine;
constructor(properties?: DirectionLineProperties);
/** The type of line which is defined by esriDirectionLineType. */
accessor directionLineType: DirectionLineType | null | undefined;
/** Length of the line measured in meters. */
accessor distance: number | null | undefined;
/** Time of the line measured in minutes. Means how much time is required to go along the line. */
accessor duration: number | null | undefined;
/** Polyline representing the direction's location. */
get geometry(): Polyline | null | undefined;
set geometry(value: PolylineProperties | 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);
get type(): "direction-line";
/**
* Creates a [Graphic](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) from the [DirectionLine](https://developers.arcgis.com/javascript/latest/references/core/rest/support/DirectionLine/) 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 DirectionLineSuperclass: typeof JSONSupport & typeof ClonableMixin