OpenLayers 3 实现划线,画点

 1 //划线    
 2     this.drawLine = function (type) {
 3         //清除双击放大效果
 4         this.map.getInteractions().item(1).setActive(false);
 5         var draw = new ol.interaction.Draw({
 6             source: _vector.getSource(),
 7             type: (type == 'point' ? 'Point' : 'LineString'),
 8             style: new ol.style.Style({
 9                 fill: new ol.style.Fill({
10                     color: 'rgba(255, 255, 255, 0.2)'
11                 }),
12                 //划线的时候的图样
13                 stroke: new ol.style.Stroke({
14                     color: 'rgba(0, 0, 0, 0.5)',
15                     lineDash: [10, 10],
16                     width: 2
17                 }),
18                 image: new ol.style.Circle({
19                     radius: 5,
20                     stroke: new ol.style.Stroke({
21                         color: 'rgba(0, 0, 0, 0.7)'
22                     }),
23                     fill: new ol.style.Fill({
24                         color: 'rgba(255, 255, 255, 0.2)'
25                     })
26                 })
27             })
28         });
29         this.map.addInteraction(draw);
30         //画好线的操作
31         draw.on('drawend', function (evt) {
32             this.map.removeInteraction(draw);            
33         },this)
34 
35         
36     }

 

posted @ 2017-03-15 15:27  破碎s  阅读(8213)  评论(0编辑  收藏  举报