博客
关于我
openlayers 入门教程(十):style 篇
阅读量:798 次
发布时间:2023-02-23

本文共 2034 字,大约阅读时间需要 6 分钟。

OpenLayers GIS??????

1. Marker??

import {Style, Circle, Fill, Stroke} from 'ol/style';var pointStyle = new Style({  image: new Circle({    radius: 5,    fill: new Fill({      color: 'red'    }),    stroke: new Stroke({      color: 'black',      width: 1    })  })});var vectorSource = new VectorSource({  // ...???});var vectorLayer = new VectorLayer({  source: vectorSource,  style: pointStyle});

2. LineString?Polygon??

var lineStyle = new Style({  stroke: new Stroke({    color: 'blue',    width: 2  })});var vectorLayer = new VectorLayer({  source: vectorSource,  style: lineStyle});

3. Polygon??

var polygonStyle = new Style({  fill: new Fill({    color: 'rgba(255, 255, 0, 0.5)'  }),  stroke: new Stroke({    color: 'black',    width: 1  })});var vectorLayer = new VectorLayer({  source: vectorSource,  style: polygonStyle});

4. ????

var textStyle = new Style({  text: new Text({    font: '14px Arial',    text: 'Label Text',    fill: new Fill({      color: '#000'    }),    stroke: new Stroke({      color: '#fff',      width: 2    }),    offsetX: 10,    offsetY: 20  })});var featureStyle = [polygonStyle, lineStyle, pointStyle, textStyle];var vectorLayer = new VectorLayer({  source: vectorSource,  style: function(feature) {    return featureStyle;  }});

5. ??????

var vectorLayer = new VectorLayer({  source: vectorSource,  style: function(feature, resolution) {    var fillColor;    if (feature.get('type') === 'important') {      fillColor = 'red';    } else {      fillColor = 'green';    }    return [      new Style({        fill: new Fill({          color: fillColor        }),        stroke: new Stroke({          color: 'black',          width: 1        })      })    ];  }});

6. ????

import {Icon} from 'ol/style';var iconStyle = new Style({  image: new Icon({    src: 'path/to/icon.png',    anchor: [0.5, 46],    anchorXUnits: 'fraction',    anchorYUnits: 'pixels',    scale: 0.5  })});var vectorLayer = new VectorLayer({  source: vectorSource,  style: iconStyle});

??????????????OpenLayers????????????GIS????????

转载地址:http://kupfk.baihongyu.com/

你可能感兴趣的文章
Objective-C实现视频流转换为图片(附完整源码)
查看>>
Objective-C实现视频除雾算法(附完整源码)
查看>>
Objective-C实现解密 Atbash 密码算法(附完整源码)
查看>>
Objective-C实现解密藏头诗(附完整源码)
查看>>
Objective-C实现解释器模式(附完整源码)
查看>>
Objective-C实现计算排列和组合的数量算法 (附完整源码)
查看>>
Objective-C实现读写蓝牙串口(附完整源码)
查看>>
Objective-C实现辗转相除法(附完整源码)
查看>>
Objective-C实现遗传算法(附完整源码)
查看>>
Objective-C实现醉汉随机行走问题(附完整源码)
查看>>
Objective-C实现重载[ ](附完整源码)
查看>>
Objective-C实现链表(附完整源码)
查看>>
Objective-C实现阶乘递归factorialRecursive算法(附完整源码)
查看>>
Objective-C实现阿特巴希密算法(附完整源码)
查看>>
Objective-C实现随机图生成器算法(附完整源码)
查看>>
Objective-C实现随机数生成器(附完整源码)
查看>>
Objective-C实现隐藏任务栏(附完整源码)
查看>>
Objective-C实现雪花算法(附完整源码)
查看>>
Objective-C实现高斯消元法(附完整源码)
查看>>
Objective-C实现高斯消除算法(附完整源码)
查看>>