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     }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM