How to draw a polygon in openlayer 3?

المشرف العام

Administrator
طاقم الإدارة
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 openlayer2

var linearRing = new OpenLayers.Geometry.LinearRing(vertices); return new OpenLayers.Geometry.Polygon([linearRing]);Here vertices is the array of points successfully drawn like the imagein openlayer 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 cant 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 cant draw a polygon



أكثر...
 
أعلى