尽管有资源,但获取资源返回 -1 - arcgis javascript

问题描述 投票:0回答:2

嘿,大家都在尝试使用 fetchResources 函数检索门户项目中的所有资源,但它返回了

nextStart : -1
resources: []
total: 0

虽然门户项目里有资源 我做错了什么?

  const item = new PortalItem({
    id: "0890f410a5314b448528f059e3083261",
    portal
  });
  await item.load();
  console.log(item.fetchResources());

资源:

arcgis esri arcgis-js-api tsx
2个回答
0
投票

这些“表”不是 ArcGIS 门户项目上下文中的“资源”。项目的具体资源取决于项目类型。请参阅示例 https://developers.arcgis.com/rest/users-groups-and-items/item-resources.htm

如果您尝试获取这些表中的数据,您可能需要创建指向这些表的要素图层(也称为非空间图层)。

参考: https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#:~:text=The%20layer%20can%20be%20either%20a%20spatial%20(有% 20地理%20特征)%20或%20非%2D空间%20(表)


0
投票

您使用 fetchResources 的方式是错误的。对于异步方法,您需要使用await

const resourcesResponse = await item.fetchResources();
const resources = resourcesResponse.resources;
console.log(resources);
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.