-
数据示例
-
代码
var styles = new ol.style.Style({
fill:new ol.style.Fill({
color: 'rgba(239,152,152, 0.5)',
}),
stroke: new ol.style.Stroke({
color: '#319FD3',
width: 1,
}),
image: new ol.style.Circle({
radius: 7,
fill: new ol.style.Fill({
color: 'red'
})
})
});
var source = new ol.layer.Tile({
source:new ol.source.OSM()
});
var format = new ol.format.WKT();
var feature = format.readFeature(POLYGON);
var vectorLayer = new ol.layer.Vector({
source:new ol.source.Vector({
features:[feature]
}),
style:styles
});
- 如果需要转换坐标的情况
var feature = format.readFeature(wkt, {
dataProjection: 'EPSG:4326',
featureProjection: 'EPSG:3857'
});