WS.InsertObject

向指定图层添加要素(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 insertObj = fs.InsertObject(layerName);

    //定义添加的要素对象
    var feature = {
            type: "Feature",
            geometry:{
                type: "Point",
                coordinates: [104.150391, 35.817813]
            }
            properties:{
                name: "名称"
            }   
        };

    //添加要素
    insertObj.insertFeature(feature,function (id) {
            alert("添加成功:id = "+ id);
        });

构造函数

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


方法

方法 返回值 描述
addFeature( < Feature > feature) void 在执行execute方法之前调用该方法,向待添加的要素数组中添加一个要素
addFeatures( < Array.< Feature > > features) void 在执行execute方法之前调用该方法,向待添加的要素数组中添加多个要素
execute( < Function > callback) void 调用后台服务,将待添加的要素数组提交到后台数据库
getFeatures() < Array.< Feature > > 获取待添加的要素数组
insertFeature( < Feature > feature, < Function > callback) void 直接调用后台服务,添加一个要素
insertFeatures( < Array.< Feature > > features, < Function > callback) void 直接调用后台服务添加多个要素
setFeatures( < Array.< Feature > > features) void 设置待添加的要素数组

results matching ""

    No results matching ""