一.引入
二.使用
//绘画缓冲
drawTurf(evt, obj) {
const geometry = evt.feature.getGeometry();
const type = geometry.getType();
// geometry.transform("EPSG:3857", "EPSG:4326");
const coords = geometry.getCoordinates();
const tf =
obj.type === "Point" ? turf.point(coords) : turf.lineString(coords);
// 缓冲区分析,turf必须使用wgs84经纬度坐标
const tbf = turf.buffer(tf, obj.distance, {
//半径
units: "kilometers", //单位
});
const obf = new GeoJSON().readFeature(tbf);
obf.setStyle(() => {
return new Style({
stroke: new Stroke({
color: "#07B9EE",
width: 2,
}),
fill: new Fill({
color: "rgba(89, 148, 241, 0.3)",
}),
});
});
this.source.addFeature(obf);
},