基本信息
以下是所在類或對象的基本信息。
AMD:
require(["esri/rest/support/TravelMode"], (TravelMode) => { /* code goes here */ });
ESM:
import TravelMode from "@arcgis/core/rest/support/TravelMode";
類:
esri/rest/support/TravelMode
繼承: TravelMode > Accessor
自從:用於 JavaScript 4.20 的 ArcGIS API
用法說明
TravelMode 是一組特征,用於定義車輛、自行車或行人等對象如何沿街道網絡移動。在尋找方向以確定車輛或行人如何行駛以及他們可以去哪裏時,會考慮這些特征。要獲取支持的出行模式列表、查找默認出行模式以及查找和使用特定出行模式,您可以使用 networkService.fetchServiceDescription() 方法:
// 1. Get the default and supported travel modes of a route service
const apiKey = "<your api key>";
const url = "https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World";
const serviceDescription = await fetchServiceDescription(url, apiKey);
const { defaultTravelMode, supportedTravelModes } = serviceDescription;
console.log(`The id of the default travel mode is: ${defaultTravelMode}.`);
console.log(`This service has ${supportedTravelModes.length} preset travel modes`);
// 2. Find and use the "Driving Time" travel mode
const apiKey = "<your api key>";
const url = "https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World";
const serviceDescription = await fetchServiceDescription(url, apiKey);
const { supportedTravelModes } = serviceDescription;
const driveTimeTravelMode = supportedTravelModes.find((mode) => mode.name === "Driving Time");
// Solve a route using the "Driving Time" travel mode
const routeParameters = {
stops: stopsFeatureSet, // route stops
travelMode: driveTimeTravelMode
};
const result = await solve(url, routeParameters);
對於ArcGIS Enterprise 服務,出行模式的默認值基於使用網絡分析函數發布Map服務時的圖層設置。打開服務說明頁麵以查看參數的默認值。
相關用法
- JavaScript Track.classes用法及代碼示例
- JavaScript Track.goToOverride用法及代碼示例
- JavaScript Track.on用法及代碼示例
- JavaScript Track.graphic用法及代碼示例
- JavaScript Track.container用法及代碼示例
- JavaScript Track用法及代碼示例
- JavaScript ArcGIS TraceLocation.percentAlong用法及代碼示例
- JavaScript Track.visible用法及代碼示例
- JavaScript Track.when用法及代碼示例
- JavaScript Track.scale用法及代碼示例
- JavaScript TimeSlider.container用法及代碼示例
- JavaScript TypedArray.sort()用法及代碼示例
- JavaScript TimeSlider.next用法及代碼示例
- JavaScript TimeSlider.mode用法及代碼示例
- JavaScript ArcGIS TimeInfo.fullTimeExtent用法及代碼示例
- JavaScript TableList trigger-action事件用法及代碼示例
- JavaScript ArcGIS TopFeaturesQuery.spatialRelationship用法及代碼示例
- JavaScript TypedArray map()用法及代碼示例
- JavaScript ArcGIS Terminal用法及代碼示例
- JavaScript TypedArray every()用法及代碼示例
- JavaScript TimeSlider.loop用法及代碼示例
- JavaScript TypedArray.indexOf()用法及代碼示例
- JavaScript TypedArray findIndex()用法及代碼示例
- JavaScript ArcGIS TileLayer layerview-create-error事件用法及代碼示例
- JavaScript ArcGIS TextSymbol3DLayer.halo用法及代碼示例
注:本文由純淨天空篩選整理自arcgis.com大神的英文原創作品 TravelMode。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。