在OpenLayers 3中,可以在所选内容中更改边框颜色:
style = new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'blue',
width: 2
})
});但是否有可能只改变边界底部呢?
类似于:
style = new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'blue',
width: 2,
border-bottom: 2px dotted #ff9900
})
});发布于 2016-02-18 14:52:12
当然,由于有了大量的OL 3资源,您可以使用第二种样式来模拟边框底部。使用ol.style#GeometryFunction。灵感来源于这个例子。
http://jsfiddle.net/jonataswalker/k11bxma2/
有点不同- http://jsfiddle.net/jonataswalker/n73gm0u9/
var style = [
new ol.style.Style({
fill: new ol.style.Fill({
color: 'rgba(255, 255, 255, 0.2)'
}),
stroke: new ol.style.Stroke({
color: 'red',
width: 2
})
}),
new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'green',
width: 2
}),
geometry: function(feature) {
var geom = feature.getGeometry();
var extent = geom.getExtent();
var bottomLeft = ol.extent.getBottomLeft(extent);
var bottomRight = ol.extent.getBottomRight(extent);
// return a linestring with the second style
return new ol.geom.LineString([bottomLeft, bottomRight]);
}
})
];https://stackoverflow.com/questions/35483007
复制相似问题