构造函数
属性概述
名称 | 类型 | 描述 | 类 |
---|---|---|---|
String | 类的名称。 更多详情 | Accessor | |
Extent | 图层的完整范围。 更多详情 | Layer | |
String | 分配给图层的唯一 ID。 更多详情 | Layer | |
InclusionModeDefinition | 更多详情 | KnowledgeGraphLayer | |
KnowledgeGraph | 包含 KnowledgeGraphLayer 数据的知识图谱服务的数据模型、服务定义和 url。 更多详情 | KnowledgeGraphLayer | |
Collection<KnowledgeGraphSublayer> | 业务 KnowledgeGraphSublayer 的集合。 更多详情 | KnowledgeGraphLayer | |
String | 指示图层在 LayerList 微件中的显示方式。 更多详情 | Layer | |
Boolean | 指示图层的资源是否已加载。 更多详情 | Layer | |
Error | 加载时发生的错误,返回 Error 对象 更多详情 | Layer | |
String | load 操作的状态 更多详情 | Layer | |
Object[] | 加载时发生的警告列表 更多详情 | Layer | |
EntityType[] | 包含在 KnowledgeGraphLayer 中的实体类型。 更多详情 | KnowledgeGraphLayer | |
RelationshipType[] | 包含在 KnowledgeGraphLayer 中的关系类型。 更多详情 | KnowledgeGraphLayer | |
Number | 图层的不透明度。 更多详情 | Layer | |
Map|Basemap|Ground|GroupLayer | 图层所属的父图层。 更多详情 | Layer | |
Collection<KnowledgeGraphSublayer> | 更多详情 | KnowledgeGraphLayer | |
String | KnowledgeGraphLayer 的可选标题。 更多详情 | KnowledgeGraphLayer | |
String | 图层类型。 更多详情 | KnowledgeGraphLayer | |
String | 知识图谱服务的 url。 更多详情 | KnowledgeGraphLayer | |
Boolean | 指示图层在 View 中是否可见。 更多详情 | Layer |
属性详细信息
-
类的名称。声明的类名称格式化为
geoscene.folder.className
。
-
图层的完整范围。默认情况下,这是全球范围的。可使用此属性设置视图的范围以匹配图层的范围,以便其要素出现在视图中。请参阅以下示例片段。
示例// Once the layer loads, set the view's extent to the layer's fullextent layer.when(function(){ view.extent = layer.fullExtent; });
-
分配给图层的唯一 ID。如果不是开发人员设置的,它将在加载图层时自动生成。
-
inclusionModeDefinition InclusionModeDefinition
-
定义要包含在图层中的一组命名类型和/或实体和关系。如果仅指定了命名类型,则该类型的所有实例都将包含在图层中。可以为图谱中的所有命名类型创建子图层,即使它们没有在成员定义中指定的实例。包含的定义不是永久动态的。在创建时,它可捕获数据。例如,如果
generateAllSublayers
为true
,且将新实体类型添加到了知识图谱,则此新实体类型将不会被添加到包含列表中。类似地,如果类型的useAllData
为true
,并且向该类型添加了一条新记录,则新添加的记录将不会自动添加到 inclusionList 中。示例// constructing an inclusion list: // The exact record ids of each of the records of a specific named type (entity type or relationship type) // to include in the layer. In this case the layer will contain one record const layerInclusionMemberDefinition = new Map(); layerInclusionMemberDefinition.set("{1A4W8G4-W52G-W89G-1W5G-J1R4S8H52H4S}",{id:"{1A4W8G4-W52G-W89G-1W5G-J1R4S8H52H4S}"}) //The layerInclusionDefinition specifies whether to use all of the data in a named type or only the records // specified in the 'members' list. In this case we only want the records specified. const layerInclusionDefinition = { useAllData: false, //only include instances in the member list members: layerInclusionMemberDefinition }; // The namedTypeDefinition is a map of the typeName of each type to be included. // In this case we are only including the "Observation" entity type. // The layerInclusionDefinition specifies exactly which "Observation" entities to include in the layer. const namedTypeDefinition = new Map(); namedTypeDefinition.set("Observation", layerInclusionDefinition); // Specify if a sublayer should be generated for all named types. // If true, a sublayer will be created for all named types regardless of // whether they have a list of instances to include or not. // If there are no instances the sublayer will be empty. In this case we have set 'generateAllSubLayers' to false so the // layer will only contain sublayers for the named types (entity types or relationship types) that are specified // in the namedTypeDefinitions. // Also defines the collection of named types to include in the layer. const inclusionListDefinition = { generateAllSublayers: false, //only create sublayers for the named types in the namedTypeDefintion namedTypeDefinitions: namedTypeDefinition }
//examples of the inclusionModeDefinition structure inside the KnowledgeGraphLayer //the layer will only contain one sublayer (for 'supplier') and that sublayer will consist of one entity. { generateAllSublayers: false, namedTypeDefinition:[{ key: "supplier", value:{ useAllData: false, members: [{ key: "{1A4W8G4-W52G-W89G-1W5G-J1R4S8H52H4S}", value: { id: "{1A4W8G4-W52G-W89G-1W5G-J1R4S8H52H4S}", } }] } }] } // this layer will contain a sublayer for all named types in the graph // ('Observation', 'User', 'Species', "Observed", "Reviewed", "ObservedIn") // but only the 'Observation' sublayer will contain data. // The Observation sublayer will contain exactly one entity. { generateAllSublayers: true, namedTypeDefinition:[{ key: "Observation", value:{ useAllData: false, members: [{ key: "{32CBD5CB-EE31-4714-B14F-57BFE36AE094}", value: { id: "{32CBD5CB-EE31-4714-B14F-57BFE36AE094}", } }] } }] } // this layer will contain a sublayer for all named types in the graph // ('Observation', 'User', 'Species', "Observed", "Reviewed", "ObservedIn") // but only the 'Observation' sublayer will contain data. // the 'Observation' sublayer will contain all instance of the Observation entity type { generateAllSublayers: true, namedTypeDefinition:[{ key: "Observation", value:{ useAllData: true } }] } // A more complex example: { //sublayers will only be created for the types listed generateAllSublayers: false, namedTypeDefinitions: { //include all `Species` entities that exist at the time the layer is created Species: { useAllData: true }, //include all `User` entities that exist at the time the layer is created User: { useAllData: true }, //include all only the specified `Observation` entities Observation: { useAllData:false, members: { "{941A7425-C45D-4940-A2E8-F3611973EC8A}": { id: "{941A7425-C45D-4940-A2E8-F3611973EC8A}" }, "{94DC1D53-4043-4D0B-8CF7-18B690414118}": { id: "{94DC1D53-4043-4D0B-8CF7-18B690414118}" }, //This entity has a fixed location so will remain in the same place regardless of the layout applied. //the other entities will move around it "{4E1D1ACE-6252-4BA4-B76E-CDEDFE9B0AB1}": { id: "{4E1D1ACE-6252-4BA4-B76E-CDEDFE9B0AB1}", linkChartLocation: new Point({x: 55.26841, y: 10.2884}) }, "{559312DF-893C-44E2-AD86-BAA73CD49719}": { id: "{559312DF-893C-44E2-AD86-BAA73CD49719}" }, "{158A2D46-3EFF-4479-BC57-E6981FCB80B6}": { id: "{158A2D46-3EFF-4479-BC57-E6981FCB80B6}" }, "{40AD70FC-CD7D-4928-B555-38EA49675944}": { id: "{40AD70FC-CD7D-4928-B555-38EA49675944}" }, "{3A5B8F11-5971-4A46-99AC-F509CA59B517}": { id: "{3A5B8F11-5971-4A46-99AC-F509CA59B517}" } } }, //include all `Observed` relationships that exist at the time the layer is created Observed: { useAllData: true }, //include all `ObservedIn` relationships that exist at the time the layer is created ObservedIn: { useAllData: true } } }
-
knowledgeGraph KnowledgeGraphreadonly
-
-
layers Collection<KnowledgeGraphSublayer>readonly
-
业务 KnowledgeGraphSublayer 的集合。每个图层表示一个实体类型或关系类型子图层。每个子图层中包含的每个要素都有一个几何,允许将其渲染为视图上具有空间上下文的图形。图层中的要素还可能包含数据属性,这些属性提供了可在弹出窗口中查看的附加信息。还可查询和分析这些图层。
示例//to access individual sublayers to add or modify properties such as the renderer, popups and labels KnowledgeGraphLayer.layers.items.forEach((sublayer)=>{ sublayer.popupTemplate = new PopupTemplate({ title: "{common_name}", content: [{ type: "text", text: "Scientific Name: {name}" }] }); })
-
指示图层在 LayerList 微件中的显示方式。下面列出了可能的值。
值 描述 show 图层在内容列表中可见。 hide 图层在内容列表中隐藏。 hide-children 如果图层是 GroupLayer、BuildingSceneLayer、KMLLayer、MapImageLayer、TileLayer 或 WMSLayer,则从内容列表中隐藏子图层。 可能值:"show"|"hide"|"hide-children"
- 默认值:"show"
-
指示图层的资源是否已加载。如果为
true
,则可访问对象的所有属性。- 默认值:false
-
加载时发生的错误,返回 Error 对象
- 默认值:null
-
load 操作的状态
值 描述 not-loaded 尚未加载 loading 正在加载 loaded 对象已加载且未出现错误 failed 无法加载对象的资源。有关更多详情,请参阅 loadError。 可能值:"not-loaded"|"loading"|"failed"|"loaded"
- 默认值:not-loaded
-
加载时发生的警告列表
-
memberEntityTypes EntityType[]readonly
-
包含在 KnowledgeGraphLayer 中的实体类型。
-
memberRelationshipTypes RelationshipType[]readonly
-
包含在 KnowledgeGraphLayer 中的关系类型。
-
图层的不透明度。此值的范围在
1
和0
之间,其中0
是 100% 透明,而1
为完全不透明。- 默认值:1
示例// Makes the layer 50% transparent layer.opacity = 0.5;
-
起始版本:GeoScene Maps SDK for JavaScript 4.27
-
图层所属的父图层。
-
tables Collection<KnowledgeGraphSublayer>readonly
-
-
title String
-
KnowledgeGraphLayer 的可选标题。
-
type Stringreadonly
-
图层类型。
对于 KnowledgeGraphLayer,类型总是 "knowledge-graph”。
-
- 默认值:true
示例// The layer is no longer visible in the view layer.visible = false;
方法概述
名称 | 返回值类值 | 描述 | 类 |
---|---|---|---|
添加一个或多个与对象生命周期相关联的句柄 更多详情 | Accessor | ||
如果 load() 操作已在进行中,则取消它。 更多详情 | Layer | ||
Promise<LayerView> | 将图层添加到 Map.layers 集合并且必须为其创建图层视图时,由视图调用,例如 MapView 和 SceneView。 更多详情 | Layer | |
销毁图层和任何相关资源 (包括其 portalItem,如果它是图层上的属性)。 更多详情 | Layer | ||
Boolean | 在实例上触发事件。 更多详情 | Layer | |
Promise<Object> | 在图层可用时,获取图层的自定义属性数据。 更多详情 | Layer | |
Boolean | 指示实例上是否存在与提供的事件名称相匹配的事件监听器。 更多详情 | Layer | |
Boolean | 如果存在指定的句柄组,则返回 true。 更多详情 | Accessor | |
Boolean |
| Layer | |
Boolean |
| Layer | |
Boolean |
| Layer | |
Promise | 加载此类引用的资源。 更多详情 | Layer | |
假设 inclusionModeDefinition 中定义的所有成员的数据已加载到本地存储中。 更多详情 | KnowledgeGraphLayer | ||
Object | 在实例上注册事件处理程序。 更多详情 | Layer | |
移除对象拥有的句柄组。 更多详情 | Accessor | ||
Promise |
| Layer |
方法详细说明
-
addHandles(handleOrHandles, groupKey)inherited
-
添加一个或多个与对象的生命周期相关联的句柄。当对象被销毁时,将移除句柄。
// Manually manage handles const handle = reactiveUtils.when( () => !view.updating, () => { wkidSelect.disabled = false; }, { once: true } ); this.addHandles(handle); // Destroy the object this.destroy();
参数handleOrHandles WatchHandle|WatchHandle[]对象销毁后,标记为要移除的句柄。
groupKey *optional标识句柄应添加到的组的键。组中的所有句柄稍后都可使用 Accessor.removeHandles() 进行删除。如果未提供键,则句柄将被添加到默认组。
-
将图层添加到 Map.layers 集合并且必须为其创建图层视图时,由视图调用,例如 MapView 和 SceneView。此方法在内部使用,没有直接调用它的用例。
参数view *父视图。
options Objectoptional指定附加选项的对象。有关此对象所需的属性,请参阅下面的对象规范表。
规范signal AbortSignaloptional中止 layerview 创建的信号。
返回类型 描述 Promise<LayerView> 使用 LayerView 实例解析。 - 另请参阅
-
destroy()inherited
-
销毁图层和任何相关资源 (包括其 portalItem,如果它是图层上的属性)。一旦图层被破坏,则无法再使用。
被破坏的图层将从其父对象中移除,例如 Map、WebMap、WebScene、Basemap、Ground 或 GroupLayer。
-
在实例上触发事件。仅当创建此类的子类时,才应使用此方法。
参数type String事件的名称。
event Objectoptional事件有效负载。
返回类型 描述 Boolean true
如果监听器收到通知,则为
-
如果存在指定的句柄组,则返回 true。
参数groupKey *optional组键。
返回类型 描述 Boolean 如果存在指定的句柄组,则返回 true
。示例// Remove a named group of handles if they exist. if (obj.hasHandles("watch-view-updates")) { obj.removeHandles("watch-view-updates"); }
-
isFulfilled()
可用于验证创建类的实例是否已完成 (已解决或已拒绝)。如果满足,则返回true
。返回类型 描述 Boolean 指示创建类的实例是否已完成 (已解决或已拒绝)。
-
isRejected()
可用于验证创建类的实例是否被拒绝。如果被拒绝,则返回true
。返回类型 描述 Boolean 指示创建类的实例是否已被拒绝。
-
isResolved()
可用于验证创建类的实例是否已解决。如果已解决,则返回true
。返回类型 描述 Boolean 指示创建类的实例是否已解决。
-
加载此类引用的资源。如果视图是使用地图实例构造的,则此方法会自动为 View 及其在 Map 中引用的所有资源执行。
开发人员在访问不会在 View 中加载的资源时,必须调用此方法。
load()
方法仅在第一次调用时触发资源的加载。随后的调用将返回相同的 promise。可以提供一个
signal
来停止对Loadable
实例加载状态感兴趣。当信号中止时,实例不会停止其加载过程,只有 cancelLoad 可以中止它。参数signal AbortSignaloptional可用于中止异步任务的信号对象。当发出中止信号时,返回的 Promise 将被拒绝,并具有一个名为
AbortError
的错误。另请参阅 AbortController 以获取有关如何构造可用于传递中止信号的控制器的更多信息。返回类型 描述 Promise 资源已加载时解析。
-
loadLayerAssumingLocalCache()static
-
假设 inclusionModeDefinition 中定义的所有成员的数据已加载到本地存储中。这将优化图层加载时间。
-
在实例上注册事件处理程序。调用此方法将事件与监听器挂钩。
参数要监听的事件或事件数组。
listener Function事件触发时要调用的函数。
返回类型 描述 Object 返回一个具有 remove()
方法的事件处理程序,应该调用该方法以停止监听事件。属性 类型 描述 remove Function 当调用时,将从事件中移除该监听器。 示例view.on("click", function(event){ // event is the event handle returned after the event fires. console.log(event.mapPoint); });
-
removeHandles(groupKey)inherited
-
移除对象拥有的句柄组。
参数groupKey *optional要移除的组键或组键的数组或集合。
示例obj.removeHandles(); // removes handles from default group obj.removeHandles("handle-group"); obj.removeHandles("other-handle-group");
-
when()
一旦创建了类的实例,就可以使用 。此方法接受两个输入参数:callback
函数和errback
函数。callback
在类的实例加载时执行。errback
在类的实例无法加载时执行。参数callback Functionoptional当 promise 解决时调用的函数。
errback Functionoptional当 promise 失败时执行的函数。
返回类型 描述 Promise 返回 callback
结果的新 promise,可用于链接其他函数。示例// Although this example uses MapView, any class instance that is a promise may use when() in the same way let view = new MapView(); view.when(function(){ // This function will execute once the promise is resolved }, function(error){ // This function will execute if the promise is rejected due to an error });
类型定义
-
InclusionModeDefinition Object
-
定义将出现在 KnowledgeGraphLayer 中的子图层结构和命名类型
- 属性
-
generateAllSublayers Boolean
指定是否为每个命名类型创建子图层,而不管它们是否包含在
namedTypeDefinition
中。如果为true
,则所有命名类型 (EntityType 和 RelationshipType) 均将添加为空子图层。namedTypeDefinitions Map<String, LayerInclusionDefinition>已命名类型的地图以及要包含在图层中的这些类型的特定实例。
-
LayerInclusionDefinition Object
-
定义
inclusionModeDefinition
中每个指定命名类型的内容,以及是否使用指定类型的所有实例或指定子集。- 属性
-
useAllData Boolean
如果为
true
,则将包括指定类型的所有实例,而不管是否存在已定义的成员列表。如果为false
,则只包括members
属性中指定的实例。members Map<String, LayerInclusionMemberDefinition>要包含的命名类型的特定成员的地图。键是实例的全局 ID。
-
LayerInclusionMemberDefinition Object
-
在
inclusionModeDefinition
中定义命名类型的members
列表。- 属性
-
id String
要包含在图层中的命名类型的特定实例的全局 ID。
事件概述
名称 | 类型 | 描述 | 类 |
---|---|---|---|
{view: View,layerView: LayerView} |
创建图层的 LayerView 并在视图中呈现后触发。 更多详情 |
Layer | |
{view: View,error: Error} |
将图层添加到地图后,在创建 LayerView 期间出现错误时触发。 更多详情 |
Layer | |
{view: View,layerView: LayerView} |
销毁图层的 LayerView 并不再在视图中呈现后触发。 更多详情 |
Layer |
事件详细说明
-
layerview-createinherited
-
创建图层的 LayerView 并在视图中呈现后触发。
示例// This function will fire each time a layer view is created for this // particular view. layer.on("layerview-create", function(event){ // The LayerView for the layer that emitted this event event.layerView; });
-
layerview-create-errorinherited
-
将图层添加到地图后,在创建 LayerView 期间出现错误时触发。
示例// This function fires when an error occurs during the creation of the layer's layerview layer.on("layerview-create-error", function(event) { console.error("LayerView failed to create for layer with the id: ", layer.id, " in this view: ", event.view); });