ol-rectangle-draw
v0.1.0
Published
This is an openlayers rectangle drawing supplement package. 这是一个openlayers矩形绘制补充包。
Downloads
3
Maintainers
Readme
ol-rectangle-draw
这是一个openlayers矩形绘制补充包。
This is an openlayers rectangle drawing supplement package.
Run Simple Demo
$ git clone https://github.com/SuperYesifang/ol-rectangle-draw.git
$ cd ol-rectangle-draw
$ npm run serve
Usage
new RectangleDraw(Draw, Polygon, options?)
1. Use CDN
<script src="https://raw.githubusercontent.com/SuperYesifang/ol-rectangle-draw/master/dist/RectangleDraw.cdn.js"></script>
<script>
const draw = new RectangleDraw(ol.interaction.Draw, ol.geom.Polygon, {
//...Draw constructor options
});
map.addInteraction(draw);
</script>
2. Use ESM
import Draw from "ol/interaction/Draw";
import Polygon from "ol/geom/Polygon";
import RectangleDraw from "ol-rectangle-draw";
const draw = new RectangleDraw(Draw, Polygon, {
//...Draw constructor options
})
map.addInteraction(draw);
Options
| prop | type | description |
| ------------ | --------- | ------------------------------------------------------------ |
| Draw
| Draw
| openlayers Draw interaction constructor. |
| Polygon
| Polygon
| openlayers Polygon geometry constructor. |
| options
| object
| Draw consturctor options (without type
and geometryFunction
) |