![8bcf38bb7e9a1e79f1bf1521dcd5c70f.png](https://img-blog.csdnimg.cn/img_convert/8bcf38bb7e9a1e79f1bf1521dcd5c70f.png)
OpenLayers可以对整个矢量图层统一设置样式,也可以单独对某个要素设置样式,本文介绍对整个矢量图层设置样式。
OpenLayers的ol.style.Style类用于设置样式,它需要结合另外三个类ol.style.Image、ol.style.Stroke、ol.style.fill分别设置点或圆的样式、边界线的样式、填充样式,另外ol.style.Text类用于设置要素注记。
来看一个示例:
样式效果:
![416c337ff8a5542367141006d7909afe.png](https://img-blog.csdnimg.cn/img_convert/416c337ff8a5542367141006d7909afe.png)
graphicStyle.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-e