@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
118 lines (116 loc) • 5.29 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 { PolylineProperties } from "../../geometry/Polyline.js";
import type { PopupTemplateProperties } from "../../PopupTemplate.js";
export interface RouteInfoProperties extends Partial<Pick<RouteInfo, "endTimeOffset" | "name" | "startTimeOffset" | "totalDistance" | "totalDuration">> {
/** The end time of the route. */
endTime?: (Date | number | string) | null;
/** Polyline representing the route's geometry. */
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 start time of the route. */
startTime?: (Date | number | string) | null;
}
/**
* A RouteInfo contains information about a solved route including the routes geometry and overall distance and time.
*
* @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
* // Display the route name and overall distance and duration.
* 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
* });
* const formatDate = new Intl.DateTimeFormat(locale, {
* year: 'numeric',
* month: 'numeric',
* day: 'numeric',
* hour: 'numeric',
* minute: 'numeric',
* second: 'numeric',
* timeZone: "America/Los_Angeles"
* });
*
* const { name, startTime, endTime, totalDistance, totalDuration } = routeLayer.routeInfo;
* console.log(`Route name: ${name}`);
* console.log(`Start Time: ${formatDate.format(startTime)}`);
* console.log(`End Time: ${formatDate.format(endTime)}`);
* console.log(`Travel Time: ${formatMinutes.format(totalDuration)} minutes`);
* console.log(`Travel Distance: ${formatDistance.format(totalDistance)} meters`);
*
* // Route name: Kenoak Pl, Pomona, California, 91768 — 16561 Valley Blvd, Fontana, California, 92335
* // Start Time: 12/7/2020, 3:58:50 PM
* // End Time: 12/7/2020, 6:12:20 PM
* // Travel Time: 133.5 minutes
* // Travel Distance: 173,148 meters
*/
export default class RouteInfo extends RouteInfoSuperclass {
/**
* Creates a [RouteInfo](https://developers.arcgis.com/javascript/latest/references/core/rest/support/RouteInfo/) 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 RouteInfo instance.
* @since 4.24
*/
static fromGraphic(graphic: Graphic): RouteInfo;
constructor(properties?: RouteInfoProperties);
/** The end time of the route. */
get endTime(): Date | null | undefined;
set endTime(value: (Date | number | string) | null | undefined);
/** The local time offset (in minutes) for the end time. */
accessor endTimeOffset: number | null | undefined;
/** Polyline representing the route's geometry. */
get geometry(): Polyline | null | undefined;
set geometry(value: PolylineProperties | null | undefined);
/** User specified route name. */
accessor name: string | 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);
/** The start time of the route. */
get startTime(): Date | null | undefined;
set startTime(value: (Date | number | string) | null | undefined);
/** The local time offset (in minutes) for the start time. */
accessor startTimeOffset: number | null | undefined;
/** Total distance traveled in meters. */
accessor totalDistance: number | null | undefined;
/** Total time in minutes. */
accessor totalDuration: number | null | undefined;
get type(): "route-info";
/**
* Creates a [Graphic](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) from the [RouteInfo](https://developers.arcgis.com/javascript/latest/references/core/rest/support/RouteInfo/) 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 RouteInfoSuperclass: typeof JSONSupport & typeof ClonableMixin