As my project requirement I want to draw a polygon look like this (>
. In this case draw polygon sides too dense for arc. Successfully draw this using LineString
but how to draw it using polygon. Need polygon because I have to fill color in between.
code in OpenLayers 2
var linearRing = new OpenLayers.Geometry.LinearRing(vertices);
return new OpenLayers.Geometry.Polygon([linearRing]);
Here vertices is the array of points successfully drawn like the image
In OpenLayers 3
var layerLines = new ol.layer.Vector({
source: new ol.source.Vector({
features: [new ol.Feature({
geometry: new ol.geom.LineString(markers, 'XY'),
})]
})
//style: iconStyle
});
map.addLayer(layerLines);
Working but can't fill the in between area.
If we replace geometry: new ol.geom.LineString(markers, 'XY'),
line by this
geometry: new ol.geom.Polygon(markers, 'XY'),
then it can't draw a polygon
Best Answer
This code is working correctly. where vertices are the array of coordinates
Demo