2015-05-14 2 views
0

после черчения функций на карте OpenLayers (наложение карты) Я хочу разобрать функции, чтобы их можно было отправить.OpenLayers3 GeoJSON разбор неправильного аргумента?

Проблема в том, что когда я вызываю getArray(), он работает, и без getArray это не так. Не следует ли parse.writeFeatures получать как paramater featureOverlay.getFeatures(), а не featureOverlay.getFeatures(). GetArray()?

 $.FooBarNS.featureOverlay = new ol.FeatureOverlay({ 
      style: new ol.style.Style({ 
      fill: new ol.style.Fill({ 
       color: 'rgba(255, 255, 255, 0.2)' 
      }), 
      stroke: new ol.style.Stroke({ 
       color: '#ffcc33', 
       width: 2 
      }), 
      image: new ol.style.Circle({ 
       radius: 7, 
       fill: new ol.style.Fill({ 
       color: '#ffcc33' 
       }) 
      }) 
      }) 
     }); 



$.FooBarNS.featureOverlay.setMap(map); 

    $('#save_polygon').click(function(){ 

     var parser = new ol.format.GeoJSON(); 
     //features = $.FooBarNS.features; 
     var features = $.FooBarNS.featureOverlay.getFeatures().getArray(); 
     console.log(features); 

     var featuresGeoJSON = parser.writeFeatures(features, {'dataProjection':'EPSG:4326','featureProjection':'EPSG:3857'}); 
     console.log(featuresGeoJSON); 
     $.ajax({ 
      type: 'POST', 
      url: 'http://gis.FooBar.com/testpolygon/', 
      dataType: 'json', 
      //contentType: 'application/json;charset=utf-8', 
      data: featuresGeoJSON 
     }).then(function(response) { 
      //console.log(response); 
     }); 


    }); 

ответ

Смежные вопросы