# Como desenhar um polígono no OpenLayers 3?

Como requisito do meu projeto, quero desenhar um polígono parecido com este(>. Neste caso, desenhe lados do polígono muito densos para o arco. Desenhe com sucesso usandoLineStringmas como desenhá-lo usando polígono. Preciso do polígono porque preciso preencher a cor entre eles.

código em OpenLayers 2

var linearRing = novo OpenLayers.Geometry.LinearRing (vértices); retornar novo OpenLayers.Geometry.Polygon ([linearRing]);

Aqui, vértices é a matriz de pontos desenhada com sucesso como a imagem no OpenLayers 3

var layerLines = new ol.layer.Vector ({fonte: new ol.source.Vector ({features: [new ol.Feature ({geometry: new ol.geom.LineString (markers, 'XY'),})]} ) // estilo: iconStyle}); map.addLayer (layerLines);

Funcionando, mas não pode preencher a área intermediária.

Se substituirmosgeometria: novo ol.geom.LineString (marcadores, 'XY'),linha por isso

geometria: novo ol.geom.Polygon (marcadores, 'XY'),

então não pode desenhar um polígono

Este código está funcionando corretamente. onde os vértices são a matriz de coordenadas

## Some Notes On Usage

### Usage - Type

The above examples demonstrate the generality/genericity of the Wykobi library routines with regards to numerical type. However this may be somewhat misleading as not all types can provide the necessary precision required to obtain satisfactory results from the routines. Consequently one must approach problems with at least some information relating to bounds and required precision and efficiency. This is a problem that a library can never solve but rather provide the end developer the tools and options by which they can make the necessary decisions to solve their problem.

### Usage - Robustness

Wykobi's routines make assumptions about the validity of types being passed to them. Typically these assumptions are manifest by the lack of assertions and type degeneracy checks within the routines themselves. This is done so as to provide the most optimal implementation of the routine without causing the routine to fail, and to leave the details of type validation to the end user as they see fit.

Theoretically each of the routines could verify object degeneracy (e.g: does the triangle have 3 unique points), then type value validity (e.g: does the value lie within some plausible range) but the unnecessary overhead one must endure would make using the routines quite inefficient. As an example consider what the circumcircle of a triangle that has all 3 of its points being collinear would look like, how would you write the routine to be robust, when would you need to have a robust routine like that?

### Usage - Correctness

Typical usage patterns involve chaining the output of one routine as the input of another so on and so forth. Not knowing the exact nature of the computation will lead to an aggregation of errors that might result in the final outcome being highly erroneous and subsequently unusable. An example of this is as follows, assume you have an arm of length x with one end statically positioned at the origin, requests for rotations of the arm come through, in degree form, +1, -13.5, +290 etc.