-
solve
(url, params, requestOptions)
{Promise<ServiceAreaSolveResult>}
根据一组参数确定服务区域。
参数:
类型 说明 url String表示网络分析服务的 ArcGIS 服务器 REST 资源的 URL。
params ServiceAreaParameters定义服务区域所需的参数。
requestOptions Object可选的 用于数据请求的附加options(将覆盖构造期间定义的 requestOptions)。
返回:
类型 说明 Promise<ServiceAreaSolveResult> 解析后,返回 ServiceAreaSolveResult 的实例。 例子:
require([ "esri/config", "esri/Map", "esri/views/MapView", "esri/rest/serviceArea", "esri/rest/support/ServiceAreaParameters", "esri/rest/support/FeatureSet", "esri/Graphic", ... ], function(esriConfig, Map, MapView, serviceArea, ServiceAreaParams, FeatureSet, Graphic, ...) { // API key from developer's account // https://developers.arcgis.com/documentation/mapping-apis-and-services/security/api-keys/ // authenticates for the basemap and the serviceArea request esriConfig.apiKey = "YOUR_API_KEY"; const map = new Map({ basemap: "arcgis-newspaper" }); const view = new MapView({ container: "viewDiv", map: map, center: [-116.53818, 33.82586] zoom: 11 }); const serviceAreaUrl = "https://route-api.arcgis.com/arcgis/rest/services/World/ServiceAreas/NAServer/ServiceArea_World/solveServiceArea"; view.on("click", function(event){ const locationGraphic = createGraphic(event.mapPoint); const serviceAreaParams = createServiceAreaParams(locationGraphic, view.spatialReference); 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({ 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/rest/serviceArea"], (serviceArea) => { /* code goes here */ });
ESM:
import * as serviceArea from "@arcgis/core/rest/serviceArea";
对象:
esri/rest/serviceArea
自从:用于 JavaScript 4.19 的 ArcGIS API
用法说明
serviceArea.solve
函数(或属性)的定义如下:
相关用法
- JavaScript setInterval()用法及代码示例
- JavaScript ArcGIS symbolUtils.getDisplayedColor用法及代码示例
- JavaScript ArcGIS scaleRange.scaleRange用法及代码示例
- JavaScript string.replace()用法及代码示例
- JavaScript ArcGIS symbolUtils.getDisplayedSymbol用法及代码示例
- JavaScript ArcGIS scheduling.addFrameTask用法及代码示例
- JavaScript ArcGIS size.createAgeRenderer用法及代码示例
- JavaScript ArcGIS size.cloneScheme用法及代码示例
- JavaScript ArcGIS sql.parseWhereClause用法及代码示例
- JavaScript ArcGIS size.createContinuousRenderer用法及代码示例
- JavaScript ArcGIS size.getSchemes用法及代码示例
- JavaScript ArcGIS scheduling.schedule用法及代码示例
- JavaScript ArcGIS size.createClassBreaksRenderer用法及代码示例
- JavaScript ArcGIS sizeRange.sizeRange用法及代码示例
- JavaScript ArcGIS symbolUtils.renderPreviewHTML用法及代码示例
- JavaScript ArcGIS symbolUtils.renderColorRampPreviewHTML用法及代码示例
- JavaScript ArcGIS size.createVisualVariables用法及代码示例
- JavaScript ArcGIS summaryStatisticsForAge.summaryStatisticsForAge用法及代码示例
- JavaScript string.anchor()用法及代码示例
- JavaScript ArcGIS summaryStatistics.summaryStatistics用法及代码示例
- JavaScript ArcGIS SceneView double-click事件用法及代码示例
- JavaScript ArcGIS geometryEngineAsync.overlaps用法及代码示例
- JavaScript ArcGIS Expand.when用法及代码示例
- JavaScript ArcGIS Sublayer.JoinTableDataSource用法及代码示例
- JavaScript ArcGIS FillSymbol3DLayer.outline用法及代码示例
注:本文由纯净天空筛选整理自arcgis.com大神的英文原创作品 serviceArea.solve。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。