I'm trying to style points in a vector source in OpenLayers 4.
I've defined a style:
var pStyle = new ol.style.Style({
stroke: new ol.style.Stroke({
width: 6, color: [255, 0, 0, 1]
})
});
and added the style in the layer definition
var pLayer = new ol.layer.Vector({
source: new ol.source.Vector({
features: [p]
}),
style: pStyle
});
Commenting the style definition makes the point appear on the map so I'm assuming the rest of the code is fine. But I can't get my point to appear in red on the map.
fiddle at: https://codepen.io/fundef/pen/VXKYjP
Where am I going wrong?
Select a geometry type from the dropdown above to start drawing. To finish drawing, click the last point. To activate freehand drawing for lines, polygons, and circles, hold the Shift key. To remove the last point of a line or polygon, press "Undo".
If you want to use fill
and stroke
var myStyle = new ol.style.Style({
image: new ol.style.Circle({
radius: 7,
fill: new ol.style.Fill({color: 'black'}),
stroke: new ol.style.Stroke({
color: [255,0,0], width: 2
})
})
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With