-
addAttachment
(feature, attachment)
{Promise<FeatureEditResult>}
向要素添加附件。仅当图层的 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/SubtypeGroupLayer"], (SubtypeGroupLayer) => { /* code goes here */ });
ESM:
import SubtypeGroupLayer from "@arcgis/core/layers/SubtypeGroupLayer";
类:
esri/layers/SubtypeGroupLayer
继承: SubtypeGroupLayer > Layer > Accessor
自从:用于 JavaScript 4.20 的 ArcGIS API
用法说明
SubtypeGroupLayer.addAttachment
函数(或属性)的定义如下:
相关用法
- JavaScript ArcGIS SubtypeGroupLayer.applyEdits用法及代码示例
- JavaScript ArcGIS SubtypeGroupLayer.on用法及代码示例
- JavaScript ArcGIS SubtypeGroupLayer.sublayers用法及代码示例
- JavaScript ArcGIS SubtypeGroupLayer.timeOffset用法及代码示例
- JavaScript ArcGIS SubtypeGroupLayer.fields用法及代码示例
- JavaScript ArcGIS SubtypeGroupLayer.maxScale用法及代码示例
- JavaScript ArcGIS SubtypeGroupLayer.layerId用法及代码示例
- JavaScript ArcGIS SubtypeGroupLayer.queryFeatureCount用法及代码示例
- JavaScript ArcGIS SubtypeGroupLayer.queryAttachments用法及代码示例
- JavaScript ArcGIS SubtypeGroupLayer.timeExtent用法及代码示例
- JavaScript ArcGIS SubtypeGroupLayer.objectIdField用法及代码示例
- JavaScript ArcGIS SubtypeGroupLayer.queryExtent用法及代码示例
- JavaScript ArcGIS SubtypeGroupLayer.fieldsIndex用法及代码示例
- JavaScript ArcGIS SubtypeGroupLayer.getFieldDomain用法及代码示例
- JavaScript ArcGIS SubtypeGroupLayer.visible用法及代码示例
- JavaScript ArcGIS SubtypeGroupLayer.refreshInterval用法及代码示例
- JavaScript ArcGIS SubtypeGroupLayer.createQuery用法及代码示例
- JavaScript ArcGIS SubtypeGroupLayer.fullExtent用法及代码示例
- JavaScript ArcGIS SubtypeGroupLayer.when用法及代码示例
- JavaScript ArcGIS SubtypeGroupLayer.effect用法及代码示例
- JavaScript ArcGIS SubtypeGroupLayer.formTemplate用法及代码示例
- JavaScript ArcGIS SubtypeGroupLayer.definitionExpression用法及代码示例
- JavaScript ArcGIS SubtypeGroupLayer.version用法及代码示例
- JavaScript ArcGIS SubtypeGroupLayer.opacity用法及代码示例
- JavaScript ArcGIS SubtypeGroupLayer.capabilities用法及代码示例
注:本文由纯净天空筛选整理自arcgis.com大神的英文原创作品 SubtypeGroupLayer.addAttachment。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。