您好,具体您可以参考https://iclient.supermap.io/examples/openlayers/editor.html#04_bufferAnalystService_geometry
/**
构造点
*/
var pointsList = [
[2823.940, -4690.000],
[3448.940, -4690.301],
[3816.561, -3810.125],
[3917.383, -3609.158],
[3976.983, -3490.291],
[4020.004, -4377.027],
[4076.265, -4382.939],
[4215.049, -4382.333],
[4428.156, -4382.285],
[4647.579, -4383.017],
[4679.707, -4382.898],
[4917.462, -4382.635],
[5074.019, -4381.833],
[5257.042, -4381.031],
[5363.785, -4380.717],
[5671.717, -4378.794],
[5847.521, -4377.970],
[5990.637, -4303.528],
[6055.343, -4270.072],
[6168.913, -4382.389],
[6214.183, -4209.927],
[6377.789, -4209.142],
[6393.692, -4210.142],
[6693.989, -4207.450],
[6788.392, -4208.450],
[6984.304, -4207.210],
[7189.183, -4208.296],
[7300.505, -4208.296],
[7573.056, -4208.803],
[7680.977, -4208.804],
[7850.593, -4208.393],
[8182.656, -4210.533],
[8554.893, -4261.485]
];
//在所有离散gps信号点添加到地图上
for (i = 0; i < pointsList.length; i++) {
var point = new ol.Feature({
geometry: new ol.geom.Point(pointsList[i])
});//构点
var pointLayer = new ol.layer.Vector({
source: new ol.source.Vector({
features: [point]
}),
style: new ol.style.Style({
image: new ol.style.Circle({
radius: 4,
fill: new ol.style.Fill({
color: 'black'
})
})
})
});
map.addLayer(pointLayer);
}
/**
构造线
*/
//将由离散gps信号点生成的线路添加到地图上
var roadLine = new ol.geom.LineString(pointsList);
var roadLineSource = new ol.source.Vector({
features: [new ol.Feature(roadLine)]
});
var roadLineLayer = new ol.layer.Vector({
source: roadLineSource,
style: new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'red',
width: 3
})
})
});
map.addLayer(roadLineLayer);
/**
构造面
*/
var polygon = new ol.geom.Polygon([[[0, 0], [-10, 30], [-30, 0], [0, 0]]]);
var polygonSource = new ol.source.Vector({
features: [new ol.Feature(polygon)],
wrapX: false
});
vectorLayer = new ol.layer.Vector({
source: polygonSource,
style: new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'red',
width: 3
}),
fill: new ol.style.Fill({
color: 'rgba(0, 0, 255, 0.1)'
})
})
});
map.addLayer(vectorLayer);