zoukankan      html  css  js  c++  java
  • ArcGIS server 开发实践之【FeatureLayer类】

    全是干活,你值得拥有

    要素图层类简介:
    Class:FeatureLayer

    //调用方式:
    require(["esri/layers/FeatureLayer"],function(FeaturLayer){});

    /*描述:
    要素图层继承几何图层,可以用来显示地图服务中的单一图层的服务或要素服务。
    要素图层可以是一个图层后者一个属性表。如果可编辑方法是true的话,要素图层中的要素可以被编辑。
    注意:arcgis 和桌面中的符号尺寸使用时点,在API for JavaScript中使用的是像素。
    */
    类的层级
    esri/layers/Layer
    esri/layers/GraphicsLayer
    esri/layers/FeatureLayer
    ----------------------------------------------
    子类:
    CSVLayer,DataAdapterFeatureLayer,StreamLayer
    -----------------------------------------------
    构造函数:
    new FeatureLayer(url,options?) // 实例化对象, url为REST服务

    new FeatrueLayer(featureCollectionObject,options?)//要素特征集实例化对象
    -----------------------------------------------
    常量:
    Name 描述
    MODE_AUTO 用于缓存,减少服务器的负载
    MODE_ONDEMAND 此种模式,要素图层可以在服务中检索我们需要的要素。
    MODE_SELECTION 在选择模式下,要素是检索服务仅选择的。此功能只在客户端可用时被选中。
    MODE_SNAPSHOT 此模式下,要素图层检索所有相关图层资源中要素将其显示在客户端上。
    POPUP_HTML_TEXT 在弹出菜单中显示html或文本信息
    POPUP_URL 弹出显示URL的类容
    SELECTION_ADD 将功能添加到当前的选择集
    SELECTION_NEW 新建一个选择
    SELECTION_SUBTRACT 从选择集中移除要素。
    ----------------------------------------------------------------------------------------------
    常用的属性:

    Name 概述
    advancedQueryCapabilities 一个对象,其中包含服务水平层元数据是否支持使用统计、查询命令字段,层次分明,分页,随着距离的查询,并返回查询扩展。
    allowGeometryUpdates 返回true,如果几何特征的层可以被编辑,否则假。
    attributionDataUrl 当URL可用时图层属性将被保存
    capabilities 支持这一图层的信息功能
    className 图层节点的类属性
    copyright 版权信息层
    dataAttributes String/String[]类型。 属性列表字段作为自定义数据属性添加到图形节点。
    defaultVisibility 显示默认图层的可见性
    displayField 显示图层字段的属性名
    editFieldsInfo 显示编辑字段的字段名
    fields 图层中的字段数组
    fullExtent 图层全部范围
    gdbVersion 地理数据库的版本
    geometryType 图层要素的集合类型
    graphics 层中的要素数组
    layerId id要素图层
    loaded 当图层加载,其值为true时可以访问图层属性
    ---------------------------------------------------------------------------------
    常用的方法:

    Name 概述
    addAttachment(objestId,formNode,callback?,errback?) 添加一个附件ObjectId所指定的功能。
    applyEdits(adds?,updates?,Deferred deletes?,callback?,errback?) 编辑应用到功能层
    attr(name,value) 添加一个新的属性或更改现有的属性的值在层的节点上。
    clear() 清除多有的图形
    clearSelection() 清除当前的选择
    disableMouseEvents() 禁用图形层上的所有鼠标事件。
    enableMouseEvents() 图层上的鼠标事件可用
    getAttributionData() 返回自定义图层的数据
    getDefintionExpression() 返回当前定义的表达式
    getDomain(fieldName,option?) 返回与给定字段相关联的域值
    getEditCapabilities(options?) 返回一个对象,描述的编辑功能层。
    getEditInfo(feature,options?) 返回一个对象描述最近的编辑操作上执行给定的特性,如果可用。
    getField(fieldName) 返回给定字段的名称
    getMap() 返回的引用添加到图层的控制层
    getOrderByFields() 返回的列表字段顺序功能使用
    getSelectionSynbol() 获取当前选择的要素
    getType(feature) 返回描述描述要素 类型的 FeatureType

    queryCount(query,callback?,errback?) 得到一个计数的数量满足输入查询的功能。
    queryFeatures(query,callback?,errback?) 在要素图层中查询要素
    queryIds(query,callback?,errback?) 查询对象ID
    queryRelatedFeatures(relQuery,callback?,errback?) 查询功能或记录,从另一个图层或表,相关功能在这一层。

    redraw() 重绘图层中多有图形
    refresh() 刷新特征图层中的要素
    remove(graphic) 移除图像
    resume() 重绘图层

    selectFeatures(query,selectionMethod?,callback?,errback?) 在要素图层中选择要素
    setEditable(editable) FeatureLayer Set the editability of feature layers created from a feature collection.
    setGDBVersion(versionName) FeatureLayer Set the layer's data source to the specified geodatabase version.
    setInfoTemplate(infoTemplate) None Specify or change the info template for a layer.
    setLabelingInfo(labelingInfo) None Sets labeling info on the layer.
    setMaxAllowableOffset(offset) None Sets the maximum allowable offset used when generalizing geometries.
    setMaxScale(scale) None Set the maximum scale for the layer.
    setMinScale(scale) None Set the minimum scale for the layer.
    setOpacity(opacity) None Initial opacity or transparency of layer.

    ---------------------------------------------------------------------------------

    构造方法:
    ------------------------------------------------------------
    new FeatureLayer(url,options?)

    <string>url :使用地图下的某一图层,必须标明
    <Object>options :可选的参数,参照可选参数表

    options properties
    .....

    Sample:

    require([
    "esri/InfoTemplate","esri/layers/FeatureLayer",...
    ],function(InfoTemplate,FeatureLayer,....){
    var infoTemplate=new InfoTemplate("${FIELD_NAME}",content);
    var featureLayer=new FeatureLayer("http://..../0",{
    mode:FeatureLayer.MODE_ONDEMAND,
    infoTemplate:infoTemplate,
    outFields:["*"]
    });
    ...
    });
    ----------------------------------------------------------------------
    new FeatureLayer(featureCollectionObject,options?)

    创建一个新的实例层使用FeatureCollection对象的特性。功能层,当初始化功能集合对象有以下行为:
    这种方法可以用来访问的可序列化的表示特性,可以保存在服务器上。


    Sample
    require([
    "esri/layers/FeatureLayr",...
    ],function(FeatureLayer,..){
    var layerDefinition={
    "geometryType":"esriGeometryPolygon",
    "fields":[{
    "name":"BUFF_DIST",
    "type":"esriFieldTypeInteger",
    "alias":"Buffer Distance"
    }]
    }
    var featureCollection={
    layerDefinition:layerDefinition,
    featuerSet:null
    };
    var featureLayer=new FeatureLayer(featureCollection,{
    showLabels:ture
    });
    ....
    });
    -------------------------------------------------------------------
    Property Details

    /*一个对象,其中包含服务水平层元数据是否支持使用统计、查询命令字段,
    层次分明,分页,随着距离的查询,并返回查询扩展。这个对象包含现有的
    属性supportsStatistics和supportsAdvancedQueries新的supportsOrderBy属性返回的。
    为了向后兼容supportsStatistics和FeatureLayer supportsAdvancedQueries仍将属性。*/
    Sample

    var wildfireResponsePointsFeatureLayer = new FeatureLayer(url, featureLayerOptions);
    map.addLayer(wildfireResponsePointsFeatureLayer);

    wildfireResponsePointsFeatureLayer.on("load", function featureLayerLoaded(event){
    console.log("advancedQueryCapabilities)", wildfireResponsePointsFeatureLayer.advancedQueryCapabilities);
    /* Object {supportsStatistics: true, supportsOrderBy: true, supportsDistinct: true} */
    });

    ----------------------------------------------------------------------------
    id

    //ID分配层。如果不指定,esri。地图分配值。
    //默认情况下,层的ID是“层”后跟一个数字。身份证只能在用户定义层的构造函数。

    1、在图层构造函数设置层id。添加指定id的动态图层


    require([
    "esri/layers/ArcGISDynamicMapServiceLayer",...
    ],function(ArcGISDynamicMapServiceLayer,..){
    var population=new ArcGISDynamicMapServiceLayer("http://....",{id:"population"});
    ...
    });
    2、设置层的ID后层初始化
    population.id="population";
    3、检索图层id
    function getMapLayers(){
    for(var j=0;jl=map.layers.length;j<jl;j++){
    var currentLayer=map.getLayer(map.layerIds[j]);
    alert("id:"+ currentLayer.id);
    }
    }

    ---------------------------------------------------------------------------
    labelingInfo
    标签信息,
    用来显示返回的信息
    Sample

    labelingInfo:[{
    "labelExpression":"",
    "labelExpressionInfo":{
    {"value":"City Of {CITY_NAME} has population{POPULATION}"}
    },
    "useCodedValues": , //参数字段属性域值时使用
    "labelPlacement":"above-right",
    "symbol":{....}, //用于标签
    "minScale":0,
    "maxScale":5000,
    //fieldInfos结构描述属性字段格式
    "fieldinfos":[
    {fieldName:"created_date", format:{dateFormat:"shortData"}},//时间或日期的格式化
    {fieldName:"last_edited_date",format:{dateFormat:"longDate"}},
    {fieldName:"eventtype",format:{places:6,digitSeparatior:ture}}//数字格式化
    ],
    "where":"POP_RAMK > AND POP_RAMK < 4"// where 条件句用于标签上
    }]

    ----------------------------------------------------





  • 相关阅读:
    工作总结(二):Web Design
    工作总结(一):Linux C
    三十分钟学会AWK
    MySQL并发复制系列二:多线程复制 2016
    修改MySQL 5.7.9版本的root密码方法以及一些新变化整理
    sync_binlog innodb_flush_log_at_trx_commit 浅析
    MariaDB的"response time"插件
    Python学习九:列表生成式
    python中的深拷贝和浅拷贝理解
    Mycat 配置
  • 原文地址:https://www.cnblogs.com/dongteng/p/5543290.html
Copyright © 2011-2022 走看看