Openlayers为线要素添加文字标注
似乎只能给点要素添加标注??
1. 加载矢量点实现标注
2. 使用重叠层实现标注
参考:https://blog.csdn.net/qq_35732147/article/details/81771953(OpenLayers之标注功能二:图文标注)
为marker添加标注:https://q.cnblogs.com/q/27959/
openlayers给要素加文字注记:https://blog.csdn.net/u013594477/article/details/83584294
openlayers文字标注 (九):https://blog.csdn.net/m0_37797410/article/details/106503770
怎么给线标注呢?
openlayers实现带箭头的线路polyline:https://zhuanlan.zhihu.com/p/336831271
How to add style in polyline in openLayers?:https://stackoverflow.com/questions/64143861/how-to-add-style-in-polyline-in-openlayers
How to add text to LineString in OpenLayers?
Setting OpenLayers line labels by angle?:https://gis.stackexchange.com/questions/333475/setting-openlayers-line-labels-by-angle
不知怎么滴,又可以了:
方法一:
text: new ol.style.Text({ font: '13px Microsoft YaHei', text: name, textAlign:"left", fill: new ol.style.Fill({ color: '#666' }), stroke: new ol.style.Stroke({ color: '#f2f', width: 1 }) }) 方法二: // text: new ol.style.Text({ // text:'aaaaa', // font: '14px Verdana', // fill: new ol.style.Fill({ // color: '#000000' // }), // stroke: new ol.style.Stroke({ // color: '#f2f', // width: 1 // }) // })