FeatureLayer图层的使用

FeatureLayer 属性

advancedQueryCapabilities:是否支持使用统计查询
allowGeometryUpdates:允许地理位置更新
attributionDataUrl:属性数据存储的 URL 地址
capabilities:要素层的信息
className:类名
copyright:版权信息
credential:认证信息
dataAttributes:数据属性
defaultDefinitionExpression:默认定义表达式
defaultVisibility:默认的图层的可见性
displayField:层的主显示字段的名称
editFieldsInfo:编辑字段的字段名
fields:字段的数组
fullExtent:要素层全图范围
geometryType:几何类型
graphics:绘制要素层数组
hasAttachments:存在附件
hasAttributionData:存在层属性数据
htmlPopupType:HTML 定义弹出气泡类型
id:唯一标示
infoTemplate:信息模板
labelingInfo:标签信息
layerId:要素层的ID
loadError:要素层未能加载报错
loaded:要素层已加载
maxRecordCount:最大记录数量
maxScale:最大比例尺
minScale:最小比例尺
multipatchOption:支持要素服务的数据源选项
name:要素层名称
objectIdField:对象ID字段
opacity:透明度
refreshInterval:刷新间隔
relationships:要素层关系
renderer:渲染器
showAttribution:显示属性
showLabels:显示标签
source:数据源
styling:样式
supportsAdvancedQueries:支持orderByFields查询操作
supportsAttachmentsByUploadId:支持上传附件
supportsCalculate:更新时,支持计算操作
supportsStatistics:支持查询操作的要素统计
surfaceType:类型的矢量图形,用来绘制图形
suspended:暂停
templates:模板

FeatureLayer 方法

add(graphic):添加一个图形
addAttachment(objectId, formNode, callback?, errback?):添加一个附件
applyEdits(adds?, updates?, deletes?, callback?, errback?):编辑应用到要素层
attr(name, value):添加一个新的属性
clear():清除所有图形
clearSelection():清除所选图形
deleteAttachments(objectId, attachmentIds, callback?, errback?):删除一个或多个附件
disableMouseEvents():禁用图形层上的所有鼠标事件
enableMouseEvents():允许图形层上的所有鼠标事件
getAttributionData():获取自定义属性数据
getDefinitionExpression():获取当前定义的表达式
getDomain(fieldName, options?):获取与给定的字段相关联的域的名称
getEditCapabilities(options?):获取编辑功能
getEditInfo(feature, options?):获取编辑信息
getEditSummary(feature, options?):获取编辑的概要信息
getField(fieldName):获取指定字段名的字段
getMap():获取地图
getMaxAllowableOffset():获取最大允许偏移
getNode():获取 DOM 节点
getOrderByFields():获取字段排序顺序
getSelectedFeatures():获取当前选择的要素
getSelectionSymbol():获取当前选择的符号
getTimeDefinition():获得当前的时间定义
getType(feature):获取要素类型
hide():隐藏某一要素层
isEditable():要素层是否可编辑
isVisibleAtScale(scale):在某一比例尺是否可见
queryAttachmentInfos(objectId, callback?, errback?):查询指定附件相关信息
queryCount(query, callback?, errback?):查询数量
queryExtent(query, callback?, errback?):查询范围
queryFeatures(query, callback?, errback?):查询特定要素
queryIds(query, callback?, errback?):查询对象ID
queryRelatedFeatures(relQuery, callback?, errback?):查询相关要素
redraw():重绘图形层中的所有图形
refresh():刷新
remove(graphic):移除图形
selectFeatures(query, selectionMethod?, callback?, errback?):选择查询
setAutoGeneralize(enable):启用或禁用自动生成
setDefinitionExpression(expression):设置定义表达式
setEditable(editable):设置要素层是否可编辑
setInfoTemplate(infoTemplate):为一层指定或更改信息模板
setLabelingInfo(labelingInfo):设置标签信息
setMaxAllowableOffset(offset):设置最大允许偏移
setMaxScale(scale):设置层的最大比例尺
setMinScale(scale):设置层的最小比例尺
setSelectionSymbol(symbol):设置选择的符号
setShowLabels(showLabels):设置是否显示标签

FeatureLayer 事件

add-attachment-complete:添加附件完成时产生的事件
before-apply-edits:编辑前触发的事件
click:单击事件
dbl-click:双击事件
delete-attachments-complete:删除附件完成后产生的事件
edits-complete:编辑完成后产生的事件
error:出现错误产生的事件
graphic-add:添加图形到GraphicsLayer产生的事件
graphic-draw:画图形到GraphicsLayer产生的事件
graphic-node-add:图形的DOM节点添加到要素层产生的事件
graphic-node-remove:图形的DOM节点移除产生的事件
graphic-remove:图形移除产生的事件
load:要素层加载产生的事件
mouse-down:鼠标按下事件
mouse-drag:鼠标拖动事件
mouse-move:鼠标移动事件
mouse-out:鼠标离开事件
mouse-over:鼠标结束事件
mouse-up:鼠标抬起事件
opacity-change:透明度改变事件
query-attachment-infos-complete:查询附件信息完成产生的事件
query-count-complete:查询数量统计完成事件
query-extent-complete:查询范围完成事件
query-features-complete:查询要素完成事件
query-ids-complete:查询id完成事件
query-related-features-complete:查询相关要素完成产生的事件
refresh-interval-change:刷新间隔改变事件
resume:图层复原产生事件
scale-range-change:比例尺范围变化产生事件
scale-visibility-chang:比例尺可见性变化产生事件
selection-clear:选择清除产生事件
selection-complete:选择完成产生事件
show-labels-change:显示标签变化产生事件
suspend:图层加载延缓时产生的事件
update:图层更新时产生的事件
update-end:图层更新结束后产生的事件
update-start:图层更新开始的事件
visibility-change:图层可见性改变时产生的事件
queryFeatures() 查询要素

http://120.78.191.67:8080/arcgis_js_api/sdk/latest/api-reference/esri-layers-FeatureLayer.html#queryFeatures

// Queries for all the features matching the layer's configurations
// e.g. definitionExpression
layer.queryFeatures().then(function(results){
  // prints the array of result graphics to the console
  console.log(results.features);
});
const layer = new FeatureLayer({
  url: fsUrl  // points to a Feature Service layer url
});

const query = new Query();
query.where = "STATE_NAME = 'Washington'";
query.outSpatialReference = { wkid: 102100 };
query.returnGeometry = true;
query.outFields = [ "CITY_NAME" ];

layer.queryFeatures(query).then(function(results){
  console.log(results.features);  // prints the array of features to the console
});
// Get a query object for the layer's current configuration
const queryParams = layer.createQuery();
// set a geometry for filtering features by a region of interest
queryParams.geometry = extentForRegionOfInterest;
// Add to the layer's current definitionExpression
queryParams.where = queryParams.where + " AND TYPE = 'Extreme'";

// query the layer with the modified params object
layer.queryFeatures(queryParams).then(function(results){
  // prints the array of result graphics to the console
  console.log(results.features);
});
const layer = new FeatureLayer({
  url: fsUrl  // points to a Feature Service layer url
});

// query all features from the layer and only return
// attributes specified in outFields.
const query = { // autocasts as Query
  where: "1=1", // select all features
  returnGeometry: false,
  outFields: ["State_Name", "City_Name", "pop2010"]
};

layer.queryFeatures(query).then(function(results){
  console.log(results.features);  // prints the array of features to the console
});

queryObjectIds() 查询ID集合

// Queries for all the Object IDs of features matching the layer's configurations
// e.g. definitionExpression
layer.queryObjectIds().then(function(results){
  // prints the array of Object IDs to the console
  console.log(results);
});
const layer = new FeatureLayer({
  url: fsUrl  // points to a Feature Service layer url
});

const query = new Query();
query.where = "region = 'Southern California'";

layer.queryObjectIds(query).then(function(ids){
  console.log(ids);  // an array of object IDs
});

猜你喜欢

转载自blog.csdn.net/jump_22/article/details/120656167