當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。