当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


JavaScript ArcGIS DirectionPoint用法及代码示例


基本信息

以下是所在类或对象的基本信息。

AMD: require(["esri/rest/support/DirectionPoint"], (DirectionPoint) => { /* code goes here */ });

ESM: import DirectionPoint from "@arcgis/core/rest/support/DirectionPoint";

类: esri/rest/support/DirectionPoint

继承: DirectionPoint > Accessor

自从:用于 JavaScript 4.23 的 ArcGIS API

用法说明

DirectionPoint 将方向项表示为具有各种显示信息的点。

例子:

// 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

相关用法


注:本文由纯净天空筛选整理自arcgis.com大神的英文原创作品 DirectionPoint。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。