-
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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。