您好!关于这个问题,如果您需要在客户端中添加的电子围栏的地物的话,首先电子围栏的地物类型需要是面要素数据集,然后通过更新面要素数据及图层来添加一个电子围栏,以下代码作为参考
//执行添加地物
function addFeatureCompleted(drawGeometryArgs) {
drawPolygon.deactivate();
var geometry = drawGeometryArgs.feature.geometry,
feature = new SuperMap.Feature.Vector();
feature.geometry = drawGeometryArgs.feature.geometry,
feature.style = style;
vectorLayer.addFeatures(feature);
geometry.id = "100000";//这里是给予几何要素的id
var editFeatureParameter,
editFeatureService,
features = {
fieldNames:[],
fieldValues:[],
geometry:geometry
};
editFeatureParameter = new SuperMap.REST.EditFeaturesParameters({
features: [features],
editType: SuperMap.REST.EditType.ADD,
returnContent:false
});
editFeatureService = new SuperMap.REST.EditFeaturesService(url2, {
eventListeners: {
"processCompleted": addFeaturesProcessCompleted,
"processFailed": processFailed
}
});
editFeatureService.processAsync(editFeatureParameter);
}
//添加地物成功
function addFeaturesProcessCompleted(editFeaturesEventArgs) {
var addResultIds = editFeaturesEventArgs.result.IDs,
resourceInfo = editFeaturesEventArgs.result.resourceInfo;
if(addResultIds === null && resourceInfo === null) return;
if((addResultIds && addResultIds.length > 0) || (resourceInfo && resourceInfo.succeed)) {
alert("新增地物成功");
vectorLayer.removeAllFeatures();
//重新加载图层
layer.redraw();
}else {
alert("新增地物失败");
}
}
接下来您需要通过intersects()的方法来判断点是否在面内