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


JavaScript ArcGIS ServiceAreaParameters.apiKey用法及代码示例


基本信息

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

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

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

类: esri/rest/support/ServiceAreaParameters

继承: ServiceAreaParameters > Accessor

自从:用于 JavaScript 4.20 的 ArcGIS API

用法说明

ServiceAreaParameters.apiKey函数(或属性)的定义如下:

apiKey String


自从:ArcGIS 适用于 JavaScript 4.21 的 API

用于访问资源或服务的授权字符串。 API keysArcGIS Developer dashboard 中生成和管理。 API key 明确绑定到ArcGIS 帐户;它还用于监视服务使用情况。在特定类上设置细粒度 API key 会覆盖 global API key

例子:

// Compute the service area for a 2km walking distance.
const url = "https://route-api.arcgis.com/arcgis/rest/services/World/ServiceAreas/NAServer/ServiceArea_World";
const apiKey = "abcdefghijklmnopqrstuvwxyz";
const spatialReference = SpatialReference.WebMercator;

const start = new Graphic({
  geometry: {
    type: "point",
    x: -13039204.060165292,
    y: 4031816.239573444,
    spatialReference
  },
  symbol: {
    type: "simple-marker",
    color: "white",
    size: 8
  }
});

const networkDescription = await fetchServiceDescription(url, apiKey);
const travelMode = networkDescription.supportedTravelModes.find(
  (travelMode) => travelMode.name === "Walking Distance"
);

const serviceAreaParameters = new ServiceAreaParameters({
  apiKey,
  facilities: new FeatureSet({
    features: [start]
  }),
  defaultBreaks: [2.5],
  travelMode,
  travelDirection: "to-facility",
  outSpatialReference: spatialReference,
  trimOuterPolygon: true
});

const results = await solve(url, serviceAreaParameters);

相关用法


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