-
createServiceAreaTask
()
{Promise<ServiceAreaTask>}
- 自從:ArcGIS 適用於 JavaScript 4.12 的 API已棄用 從 4.21 版本開始。請使用 serviceArea 和 helperServices 代替。
一個幫助函數,它返回門戶的 ServiceAreaTask helper service 的實例。
返回:
類型 說明 Promise<ServiceAreaTask> 解析後,返回 ServiceAreaTask 的實例。 例子:
// example using "esri/rest/serviceArea" with helperServices require([ "esri/portal/Portal", "esri/rest/serviceArea", "esri/rest/support/ServiceAreaParameters", "esri/rest/support/FeatureSet", "esri/Graphic", ... ], function(Portal, serviceArea, ServiceAreaParams, FeatureSet, Graphic, ...) { // create new Portal object with relevant URL const portal = new Portal({ url: "YOUR_PORTAL_URL" }); // load Portal instance portal.load(); view.on("click", function(event){ const locationGraphic = createGraphic(event.mapPoint); const serviceAreaParams = createServiceAreaParams(locationGraphic, view.spatialReference); const serviceAreaUrl = portal.helperServices.serviceArea.url; solveServiceArea(serviceAreaUrl, serviceAreaParams); }); // Create the location graphic function createGraphic(point) { view.graphics.removeAll(); const graphic = new Graphic({ geometry: point, symbol: { type: "simple-marker", color: "white", size: 8 } }); view.graphics.add(graphic); return graphic; } function createServiceAreaParams(locationGraphic, outSpatialReference) { // Create one or more locations (facilities) to solve for const featureSet = new FeatureSet({ features: [locationGraphic] }); // Set all of the input parameters for the service const serviceAreaParameters = new ServiceAreaParams({ apiKey: "YOUR_API_KEY", facilities: featureSet, trimOuterPolygon: true, outSpatialReference: outSpatialReference }); return serviceAreaParameters; } function solveServiceArea(url, serviceAreaParams) { return serviceArea.solve(url, serviceAreaParams) .then(function(result){ if (result.serviceAreaPolygons.length) { // Draw each service area polygon result.serviceAreaPolygons.forEach(function(graphic){ graphic.symbol = { type: "simple-fill", color: "rgba(62,13,94,.25)" } view.graphics.add(graphic,0); }); } }, function(error){ console.log(error); }); } });
基本信息
以下是所在類或對象的基本信息。
AMD:
require(["esri/portal/Portal"], (Portal) => { /* code goes here */ });
ESM:
import Portal from "@arcgis/core/portal/Portal";
類:
esri/portal/Portal
繼承: Portal > Accessor
自從:用於 JavaScript 4.0 的 ArcGIS API
用法說明
Portal.createServiceAreaTask
函數(或屬性)的定義如下:
相關用法
- JavaScript ArcGIS Portal.createPrintTask用法及代碼示例
- JavaScript ArcGIS Portal.createRouteTask用法及代碼示例
- JavaScript ArcGIS Portal.fetchBasemaps用法及代碼示例
- JavaScript ArcGIS Portal.queryItems用法及代碼示例
- JavaScript ArcGIS Portal.when用法及代碼示例
- JavaScript ArcGIS Portal.fetchCategorySchema用法及代碼示例
- JavaScript ArcGIS Portal.fetchFeaturedGroups用法及代碼示例
- JavaScript ArcGIS Portal.helperServices用法及代碼示例
- JavaScript ArcGIS Portal.queryUsers用法及代碼示例
- JavaScript ArcGIS PortalItem.id用法及代碼示例
- JavaScript ArcGIS PortalItem.isLayer用法及代碼示例
- JavaScript ArcGIS PortalItem.addResource用法及代碼示例
- JavaScript ArcGIS PortalItem.destroy用法及代碼示例
- JavaScript ArcGIS PortalItem.portal用法及代碼示例
- JavaScript ArcGIS PortalUser.fetchItems用法及代碼示例
- JavaScript ArcGIS PortalItem.fetchRelatedItems用法及代碼示例
- JavaScript ArcGIS Portal用法及代碼示例
- JavaScript ArcGIS PortalQueryParams.categories用法及代碼示例
- JavaScript ArcGIS PortalGroup.fetchMembers用法及代碼示例
- JavaScript ArcGIS PortalUser.fetchGroups用法及代碼示例
- JavaScript ArcGIS PortalItem.when用法及代碼示例
- JavaScript ArcGIS PortalItem.type用法及代碼示例
- JavaScript ArcGIS PortalUser.fetchFolders用法及代碼示例
- JavaScript ArcGIS PortalGroup.fetchCategorySchema用法及代碼示例
- JavaScript ArcGIS PortalItem.fetchResources用法及代碼示例
注:本文由純淨天空篩選整理自arcgis.com大神的英文原創作品 Portal.createServiceAreaTask。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。