地物编辑
地物编辑功能可以实现在地图中添加或删除要素。使用接口 mapboxgl.supermap.FeatureService 在数据集中添加地物信息。
// 实例化地物编辑服务
let url="https://iserver.supermap.io/iserver/services/data-world/rest/data"
let xmax = 120, xmin = 100, ymax = 50, ymin = 20
let addPoint = [Math.floor(Math.random() * (xmax - xmin + 1) + xmin), Math.floor(Math.random() * (ymax - ymin + 1) + ymin)]
let pointFeature = {
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": addPoint
},
"properties": {POP: 1, CAPITAL: 'test'}
}
let featureService = new mapboxgl.supermap.FeatureService(url)
// 设置地物编辑字段参数
let addFeatureParams = new mapboxgl.supermap.EditFeaturesParameters({
dataSourceName: "World",
dataSetName: "Capitals",
features: pointFeature,
editType: "add",
returnContent: true
})
// 使用地物编辑服务向服务端发送请求并获取数据
featureService.editFeatures(addFeatureParams).then(function (serviceResult) {
// 获取返回数据
let result = serviceResult.result
})