openlayers - 矢量层的自定义样式

标签 openlayers

我想更改 map 图层中矢量要素的默认样式。 阅读文档后,我写了以下内容:

var myStyle = new OpenLayers.Style({fill: true,fillColor: "#ff0000"});
var vector_layer = new OpenLayers.Layer.Vector('CODLayer', {style: myStyle});

但是我把所有功能都弄黑了...你知道我缺少什么吗?

最佳答案

我通过以下方式解决了:

var myStyle = {fill: true,fillColor: "#ff0000"};
var vector_layer = new OpenLayers.Layer.Vector('CODLayer', {style: myStyle});

here 为例.

关于openlayers - 矢量层的自定义样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10614991/

相关文章:

javascript - 如何使用 forEachFeatureAtPixel 方法过滤图层

css - Openlayers 在带有填充的 map 上弹出 autoPan

reactjs - React 中的 Openlayers 弹出窗口 |如何?

javascript - 在 OpenLayers 中拥有多边形的 removeLastPoint() 函数

javascript - 添加特征之前进行 OpenLayers 拟合

javascript - 如何在带有 OpenLayers 的一张 map 中使用带有经纬度图层的 Mapnik-Backgroundlayer?

javascript - OpenLayers map 未渲染

android - Android 中的 OpenLayers

OpenLayers GeoRSS 解析 - 所有点都在彼此之上

javascript - 根据属性在Openlayers中搜索wms图层,如果找到就放大