EditorViewModel

AMD: require(["geoscene/widgets/Editor/EditorViewModel"], (EditorVM) => { /* code goes here */ });
ESM: import EditorVM from "@geoscene/core/widgets/Editor/EditorViewModel";
类: geoscene/widgets/Editor/EditorViewModel
继承于:EditorViewModel Accessor
起始版本:GeoScene API for JavaScript 4.11

提供编辑器微件的逻辑。

另请参阅:
示例:
const editor = new Editor({
  viewModel: { // autocasts as new EditorViewModel
    layerInfos: [{
      layer: featureLayer,
      deleteEnabled: false // disables deleting features
    }]
  }
});

构造函数

new EditorViewModel(properties)
参数:
properties Object
optional

有关可能传递到构造函数中的所有属性的列表,请参阅属性

属性概述

可以设置、检索或侦听任何属性。请参阅使用属性主题。
显示继承的属性 隐藏继承的属性
名称 类型 描述 类:
CreateWorkflow|CreateFeaturesWorkflow|UpdateWorkflow更多详情

指示当前活动工作流的属性。

更多详情EditorViewModel
String更多详情

一个字符串值数组,它指定允许最终用户编辑的内容。

更多详情EditorViewModel
AttachmentsViewModel更多详情

用于支持编辑器微件的 AttachmentsViewModel

更多详情EditorViewModel
Boolean更多详情

便利性属性,用于读取是否存在任何支持 create-features 工作流的可编辑图层。

更多详情EditorViewModel
Boolean更多详情

便利性属性,用于读取是否存在任何支持 update 工作流的可编辑图层。

更多详情EditorViewModel
String更多详情

类的名称。

更多详情Accessor
Collection<EditableItem>更多详情

与正在更新的要素匹配的可编辑项对象的集合。

更多详情EditorViewModel
Object[]更多详情

一个对象数组,其中包含特定于任何失败的编辑操作的信息。

更多详情EditorViewModel
FeatureFormViewModel更多详情

用于支持编辑器微件的 FeatureFormViewModel

更多详情EditorViewModel
FeatureTemplatesViewModel更多详情

用于支持编辑器微件的 FeatureTemplatesViewModel

更多详情EditorViewModel
LayerInfo[]更多详情

单个图层的编辑配置数组。

更多详情EditorViewModel
SketchViewModel更多详情

用于支持编辑器微件的 SketchViewModel

更多详情EditorViewModel
SnappingOptions更多详情

用于草绘的 SnappingOptions

更多详情EditorViewModel
String更多详情

微件的状态。

更多详情EditorViewModel
Boolean更多详情

true 时,至少有一个编辑请求正在处理中。

更多详情EditorViewModel
MapView|SceneView更多详情

MapViewSceneView 的引用。

更多详情EditorViewModel

属性详细信息

指示当前活动工作流的属性。这是 CreateFeaturesWorkflow 或者 UpdateWorkflow。如果 useDeprecatedCreateWorkflowtrue,则此属性类型反映已弃用的 CreateWorkflow

另请参阅:
allowedWorkflows String

一个字符串值数组,它指定允许最终用户编辑的内容。例如,可能具有完全编辑权限的要素图层可用。但您可能只希望最终用户能够更新现有要素。将 allowedWorkflows 设置为仅 update

可能值 说明
create 这允许最终用户在要素服务中创建新的单个要素。(自 4.23 起已弃用,使用 create-features 如下所述。)
create-features 这允许最终用户在要素服务中创建单个要素或连续要素。(自 4.23 起)
update 这允许最终用户更新和/或删除要素服务中的要素。

仅当要素服务允许这些操作时,才会启用这些工作流。

可能值:"create-features"|"create"|"update"

attachmentsViewModel AttachmentsViewModel

用于支持编辑器微件的 AttachmentsViewModel。默认情况下,附件编辑处于启用状态。

canCreate Booleanreadonly

便利性属性,用于读取是否存在任何支持 create-features 工作流的可编辑图层。

canUpdate Booleanreadonly

便利性属性,用于读取是否存在任何支持 update 工作流的可编辑图层。

declaredClass Stringreadonly inherited

类的名称。声明的类名格式为 geoscene.folder.className

editableItems Collection<EditableItem>readonly

与正在更新的要素匹配的可编辑项对象的集合。

failures Object[]readonly

一个对象数组,其中包含特定于任何失败的编辑操作的信息。除了错误之外,还提供了 retry()cancel() 的选项。

属性:
error Error

只读错误消息。

featureFormViewModel FeatureFormViewModel

用于支持编辑器微件的 FeatureFormViewModel

featureTemplatesViewModel FeatureTemplatesViewModel

用于支持编辑器微件的 FeatureTemplatesViewModel

layerInfos LayerInfo[]

单个图层的编辑配置数组。

如果您具有可编辑的要素图层,但不希望最终用户执行任何类型的编辑,则可以通过将 enabled 属性设置为 false 来限制此程度。

示例:
const editorViewModel = new EditorViewModel({
  layerInfos: [{
    view: view,
    layer: featureLayer, // pass in the feature layer,
    formTemplate:  { // autocastable to FormTemplate
      elements: [
        { // autocastable to FieldElement
          type: "field",
          fieldName: "fulladdr",
          label: "Full Address"
        }
      ]
    },
    enabled: true, // default is true, set to false to disable editing functionality
    addEnabled: true, // default is true, set to false to disable the ability to add a new feature
    updateEnabled: false // default is true, set to false to disable the ability to edit an existing feature
    deleteEnabled: false // default is true, set to false to disable the ability to delete features
  }]
});
sketchViewModel SketchViewModel

用于支持编辑器微件的 SketchViewModel

snappingOptions SnappingOptionsautocast
起始版本:GeoScene API for JavaScript 4.19

用于草绘的 SnappingOptions。它支持自拍要素捕捉。

state Stringreadonly

微件的状态。可能的值如下表所示。

说明
ready 满足依赖项并具有有效的属性值。
disabled 依赖项丢失,无法提供有效的输入。
editing-new-feature 编辑器当前正在编辑(创建)新要素,并且仅适用于已弃用的 CreateWorkflow
editing-existing-feature 编辑器当前正在编辑现有要素。
awaiting-update-feature-candidate 应用程序在单击更新后等待用户输入的时间段,将返回多个要素。指定要更新的要素。
awaiting-feature-creation-info 这是 create-features 工作流中的第一步。CreationInfo 是必需项。
awaiting-feature-to-update 这是 update 工作流中的第一步。features 是必需项。
awaiting-feature-to-create 在执行属性/几何编辑之前创建要素的等待期。
adding-attachment 如果当前 editing-existing-feature 和向现有要素添加附件。
editing-attachment 如果当前 editing-existing-feature 和正在更新现有附件到现有要素。
creating-features 编辑器当前正在创建多个要素。

可能值"ready"|"disabled"|"editing-new-feature"|"editing-existing-feature"|"awaiting-update-feature-candidate"|"awaiting-feature-creation-info"|"awaiting-feature-to-update"|"awaiting-feature-to-create"|"adding-attachment"|"editing-attachment"|"creating-features"

默认值:disabled
syncing Booleanreadonly

true 时,至少有一个编辑请求正在处理中。

MapViewSceneView 的引用。此视图为编辑器微件提供可编辑的图层。

方法概述

名称 返回类型 描述 类:
Promise<void>更多详情

取消任何活动工作流。

更多详情EditorViewModel
Promise<void>更多详情

如果存在活动的更新工作流,则此方法适用。

更多详情EditorViewModel
Promise<void>更多详情

通过显示开始创建要素的面板来启动 CreateFeaturesWorkflow

更多详情EditorViewModel
Promise<void>更多详情

通过显示 FeatureTemplates 面板来启动 CreateFeaturesWorkflow

更多详情EditorViewModel
Promise<void>更多详情

通过显示开始要素创建的面板来启动 CreateWorkflow

更多详情EditorViewModel
Promise<void>更多详情

此方法将启动 CreateWorkflow,在其中等待选择要素。

更多详情EditorViewModel
Promise<void>更多详情

通过显示 FeatureTemplates 面板来启动 CreateWorkflow

更多详情EditorViewModel
Promise<void>更多详情

在要素几何和属性编辑面板上启动更新工作流。

更多详情EditorViewModel
Promise<void>更多详情

使用当前所选要素启动 update 工作流。

更多详情EditorViewModel
Promise<void>更多详情

启动编辑器工作流,在该工作流中等待选择多个要素。

更多详情EditorViewModel

方法详细信息

cancelWorkflow(){Promise<void>}

取消任何活动工作流。

返回:
类型 说明
Promise<void> 取消工作流后解析。
deleteFeatureFromWorkflow(){Promise<void>}

如果存在活动的更新工作流,则此方法适用。如果是这样,此方法将删除工作流要素。

返回:
类型 说明
Promise<void> 删除活动 UpdateWorkflow 后解析。
另请参阅:
startCreateFeaturesWorkflowAtFeatureCreation(creationInfo){Promise<void>}
起始版本:GeoScene API for JavaScript 4.23

通过显示开始创建功能的面板来启动 CreateFeaturesWorkflow。此方法采用包含要使用的图层和模板的 CreationInfo 对象。

参数:
creationInfo CreationInfo

包含使用编辑器微件创建新要素所需信息的对象。此对象提供用于创建新要素的要素模板和图层。

返回:
类型 说明
Promise<void> 解决 CreateFeaturesWorkflow 启动时的问题,并显示开始创建要素的面板。
startCreateFeaturesWorkflowAtFeatureTypeSelection(){Promise<void>}
起始版本:GeoScene API for JavaScript 4.23

通过显示 FeatureTemplates 面板来启动 CreateFeaturesWorkflow

返回:
类型 说明
Promise<void> 在启动 CreateFeaturesWorkflow 时解析并显示 FeatureTemplates 面板。
startCreateWorkflowAtFeatureCreation(creationInfo){Promise<void>}
已弃用自版本 4.23 起。而是使用 startCreateFeaturesWorkflowAtFeatureCreation

通过显示开始要素创建的面板来启动 CreateWorkflow。此方法采用包含要使用的图层和模板的 CreationInfo 对象。

参数:
creationInfo CreationInfo

包含使用编辑器微件创建新要素所需信息的对象。此对象提供用于创建新要素的要素模板和图层。

返回:
类型 说明
Promise<void> 解决 CreateFeaturesWorkflow 启动时的问题,并显示开始创建要素的面板。
startCreateWorkflowAtFeatureEdit(feature){Promise<void>}
已弃用(自 4.23 起)

此方法将启动 CreateWorkflow,在其中等待选择要素。

参数:
feature Graphic

要编辑的要素。

返回:
类型 说明
Promise<void> CreateWorkflow 启动后解析,显示开始创建要素的面板,并等待选择要素。
另请参阅:
startCreateWorkflowAtFeatureTypeSelection(){Promise<void>}
已弃用自版本 4.23 起。而是使用 startCreateFeaturesWorkflowAtFeatureTypeSelection

通过显示 FeatureTemplates 面板来启动 CreateWorkflow

返回:
类型 说明
Promise<void> 在启动 CreateWorkflow 时解析并显示 FeatureTemplates 面板。
另请参阅:
startUpdateWorkflowAtFeatureEdit(feature){Promise<void>}

在要素几何和属性编辑面板上启动更新工作流。

参数:
feature Graphic

要更新的要素。

返回:
类型 说明
Promise<void> UpdateWorkflow 启动要素几何和属性编辑面板后解析。
另请参阅:
startUpdateWorkflowAtFeatureSelection(){Promise<void>}

使用当前所选要素启动 update 工作流。

返回:
类型 说明
Promise<void> 在使用当前所选要素启动 UpdateWorkflow 后解析。
另请参阅:
startUpdateWorkflowAtMultipleFeatureSelection(){Promise<void>}

启动编辑器工作流,在该工作流中等待选择多个要素。

返回:
类型 说明
Promise<void> 在启动 UpdateWorkflow 时解析,因为它等待选择多个要素。
另请参阅:

类型定义

EditableItem

地图中可用的可编辑项目。

属性:

只读与可编辑项目关联的要素图层。

supports String

只读此项目支持的工作流类型。可以是 updatecreate-features

您的浏览器不再受支持。请升级浏览器以获得最佳体验。有关更多详细信息,请参阅我们的 浏览器弃用帖子