/*
绘制矩形范围,截图保存到本地
*/
import VectorSource from 'ol/source/Vector';
import Draw, {
createBox
} from 'ol/interaction/Draw'
import {
Fill,
Stroke,
Style
} from 'ol/style';
// 绘制矩形后,截图保存到本地
export function drawMap(map, imgName) {
const source = new VectorSource({
wrapX: false
});
let draw = new Draw({
source: source,
type: 'Circle',
style: new Style({
stroke: new Stroke({
color: 'blue',
width: 2,
}),
fill: new Fill({
color: 'rgba(0, 0, 0, 0)',
}),
}),
geometryFunction: createBox()
})
map.addInteraction(draw);
draw.on('drawend', (evt) => {
// source.clear();
map.removeInteraction(draw);
console.log(evt);
map.renderSync();
let extent = evt.feature.getGeome