Open Layers Generate Poligonos Maps

0

Good afternoon I am generating polygons on a map with OpenLayers. I get the coordinates with a web method from the database and I generate coordinate arrays to be used in the polygons.

The problem I have is when executing the following code:

 var poly = new ol.Feature({
  geometry: new ol.geom.Polygon([coordenadas.map(({lng, lat})=>[lng, lat])])
 })

And in chrome I get the following:

And I do not know what the error may be. Thank you very much for your help.

    function generarMapas(){

    var FechaInicial='';
    var FechaFinal='';
    var Finca='';
    $.ajax({
        type: "POST",
        url: "FrmMapaAvanceRiego.aspx\/FillMapas",
        data: '{FechaInicial: "' + FechaInicial + '", FechaFinal: "' + FechaFinal + '", Finca: "' + Finca + '"}',
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            var data = JSON.parse(msg.d);
                coordenadas = [];
            $.each(data, function (i, item) {
                coordenadas[i] = item.Coordenadas;
                crearPoligonos(coordenadas[i]);
            });
        },
        error: errores
    });

  }

  function errores(msg) {
    alert('Error: ' + msg.responseText);
  }

  function crearPoligonos(coordenada) {

    var coordenadas = coordenada.split(' ') // Separamos por espacio
.map(function (data) {
    var info = data.split(','), // Separamos por coma
        coord = { // Creamos el obj de coordenada
            lat: parseFloat(info[1]),
            lng: parseFloat(info[0])
        };
    return coord;
});
console.log(coordenadas);
var parserJSTS = new jsts.io.OL3Parser();

var poly = new ol.Feature({
    geometry: new ol.geom.Polygon([coordenadas.map(({lng, lat})=>[lng, lat])])
})

}
    
asked by raintrooper 30.11.2017 в 22:45
source

0 answers