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


JavaScript ArcGIS RouteLayer.save用法及代码示例


基本信息

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

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

ESM: import RouteLayer from "@arcgis/core/layers/RouteLayer";

类: esri/layers/RouteLayer

继承: RouteLayer > Layer > Accessor

自从:用于 JavaScript 4.23 的 ArcGIS API

用法说明

RouteLayer.save函数(或属性)的定义如下:

save () {Promise<PortalItem>}


使用此 RouteLayer 中的信息更新当前分配的 portal item

返回:

类型 说明
Promise<PortalItem> 已保存的门户项目。

例子:

// Create a route layer from an existing route portal item
const routeLayer = await Layer.fromPortalItem({
  portalItem: {
    id: "3828dfec3a0749a1b1aff9e2fa53157c"
  }
});

// Add the route layer to a map
map.add(routeLayer);

// Wait for both the view and route layer to load
await view.whenLayerView(routeLayer);

// Zoom to the extent of the route layer
await view.goTo(routeLayer.fullExtent);

// Update the route portal item on mouse click
view.on("click", async (event) => {
  // Reset the route layer's stops with the mouse click location being a waypoint
  routeLayer.stops = [
    { geometry: { x: -86.9074392, y: 21.0847238 } }, // Cancun Airport
    { geometry: event.mapPoint },                    // Mouse click location
    { geometry: { x: -88.1331506, y: 20.6354437 } }  // Chichén Itzá
  ];

  // Solve the route
  const result = await routeLayer.solve({ apiKey });

  // Use the results of the solve to update the route layer
  routeLayer.update(result);

  // Refresh the route portal-item using the route layer
  await routeLayer.save();
});

相关用法


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