-
addAttachment
(feature, attachment)
{Promise<FeatureEditResult>}
- 自从:ArcGIS 适用于 JavaScript 4.9 的 API
向要素添加附件。仅当图层的 capabilities.data.supportsAttachment 设置为
true
时,此操作才可用。参数:
类型 说明 feature Graphic要添加附件的要素。
attachment HTMLFormElement|FormData包含文件上传字段的 HTML 表单,该字段指向要作为附件添加的文件。
返回:
类型 说明 Promise<FeatureEditResult> 解析后,将返回 FeatureEditResult 对象。 FeatureEditResult 表示编辑是否成功。如果成功,结果的 objectId
是新附件的 Id。如果不成功,它还包括错误name
和错误message
。例子:
view.when(function () { view.on("click", function (event) { view.hitTest(event).then(function (response) { const feature = response.results[0].graphic; // The form is defined as below in the html. // For enterprise services: // 1. File input name must be "attachment" // <form id="attachmentForm"> // Select a file: <input type="file" name="attachment"> // </form> const attachmentForm = document.getElementById("attachmentForm"); const formData = new FormData(attachmentForm); // For enterprise services - add input with name:f and value:json formData.append("f","json"); const form = new FormData(); form.set("attachment", file); form.append("f","json") let form = document.getElementById("myForm"); // Add an attachment to the clicked feature. // The attachment is taken from the form. layer.addAttachment(feature, form).then(function (result) { console.log("attachment added: ", result); }) .catch(function (err) { console.log("attachment adding failed: ", err); }); }); }); });
基本信息
以下是所在类或对象的基本信息。
AMD:
require(["esri/layers/FeatureLayer"], (FeatureLayer) => { /* code goes here */ });
ESM:
import FeatureLayer from "@arcgis/core/layers/FeatureLayer";
类:
esri/layers/FeatureLayer
继承: FeatureLayer > Layer > Accessor
自从:用于 JavaScript 4.0 的 ArcGIS API
用法说明
FeatureLayer.addAttachment
函数(或属性)的定义如下:
相关用法
- JavaScript ArcGIS FeatureLayer.apiKey用法及代码示例
- JavaScript ArcGIS FeatureLayer.applyEdits用法及代码示例
- JavaScript ArcGIS FeatureLayer.queryExtent用法及代码示例
- JavaScript ArcGIS FeatureLayer.when用法及代码示例
- JavaScript ArcGIS FeatureLayer.getFieldDomain用法及代码示例
- JavaScript ArcGIS FeatureLayer.queryFeatureCount用法及代码示例
- JavaScript ArcGIS FeatureLayer.formTemplate用法及代码示例
- JavaScript ArcGIS FeatureLayer.relationships用法及代码示例
- JavaScript ArcGIS FeatureLayer.objectIdField用法及代码示例
- JavaScript ArcGIS FeatureLayer.opacity用法及代码示例
- JavaScript ArcGIS FeatureLayer.queryRelatedFeatures用法及代码示例
- JavaScript ArcGIS FeatureLayer.datesInUnknownTimezone用法及代码示例
- JavaScript ArcGIS FeatureLayer.featureEffect用法及代码示例
- JavaScript ArcGIS FeatureLayer.timeInfo用法及代码示例
- JavaScript ArcGIS FeatureLayer.createQuery用法及代码示例
- JavaScript ArcGIS FeatureLayer.queryRelatedFeaturesCount用法及代码示例
- JavaScript ArcGIS FeatureLayer.outFields用法及代码示例
- JavaScript ArcGIS FeatureLayer.version用法及代码示例
- JavaScript ArcGIS FeatureLayer.fullExtent用法及代码示例
- JavaScript ArcGIS FeatureLayer.visible用法及代码示例
- JavaScript ArcGIS FeatureLayer.labelingInfo用法及代码示例
- JavaScript ArcGIS FeatureLayer.maxScale用法及代码示例
- JavaScript ArcGIS FeatureLayer.queryTopObjectIds用法及代码示例
- JavaScript ArcGIS FeatureLayer.queryTopFeatureCount用法及代码示例
- JavaScript ArcGIS FeatureLayer.on用法及代码示例
注:本文由纯净天空筛选整理自arcgis.com大神的英文原创作品 FeatureLayer.addAttachment。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。