WS.UpdateObject

修改指定图层中的要素(Feature)。


示例

   var wsApiBasePath = "//api.dituyi.com.cn";//API地址
    var wsApiKey = "6296431363854d62a1bffc31ee7dd6a2";//用户key
    var wsConf = {
        apiBasePath: wsApiBasePath,
        apiKey: wsApiKey
    };
    var wServer = new WS.WServer(wsConf);//服务连接
    var fs = new WS.WServer(wsConf).createFeatureService();//创建要素服务

    //创建修改要素对象
    var layerName = "msp_demo_pt";//
    var updateObj = fs.UpdateObject(layerName);

    //要修改的要素对象,id是唯一的
    var feature = {
            type: "Feature",
            id:19,
            geometry:{
                type: "Point",
                coordinates: [104.150391, 35.817813]
            }
            properties:{
                name: "名称"
            }   
        };

    updateObj.updateFeature(feature,function () {
            resultLayer.updateFeature(id,feature);
            showPopup(feature);
        });

构造函数

通过WS.FeatureService类的UpdateObject(layerName)方法创建WS.UpdateObject对象。


方法

方法 返回值 描述
addFeature( < Feature > feature) void 向待修改的要素数组中添加一个要素
addFeatures( < Array.< Feature > > features) void 向待修改的要素数组中添加多个要素
execute( < Function > callback) void 调用后台服务,将待修改的要素数组提交到后台
getFeatures() Array.< Feature > 获取待修改的要素数组
setFeatures( < Array.< Feature > > features) void 设置待修改的要素数组
updateFeature( < Feature > feature, < Function > callback) void 直接调用后台服务,更新一个要素
updateFeatures( < Array.< Feature > > features, < Function > callback) void 直接调用后台服务,更新多个要素

results matching ""

    No results matching ""