2

I had this code for my turf-buffer :

var unidades = 'kilometers'
select2 = new ol.interaction.Select({
    condition: ol.events.condition.click
});

map.addInteraction(select2);    
select2.getFeatures().on('change:length', function(e){   

    var feature_buff = select2.getFeatures();   
    var geojson  = new ol.format.GeoJSON();

    for (var i=0;i<feature_buff.getLength();i++){

        json.push(geojson.writeFeature(feature_buff.item(i)));
        prueba.getSource().addFeature(geojson.readFeature(json[json.length-1]) );
        polys_fc=JSON.parse(json[json.length-1]);

        prueba.getSource().addFeatures(geojsonToFeatures(polys_fc, {
            featureProjection: 'EPSG:3857'
        }));

        var buffer = turf.buffer(polys_fc, 100, unidades); // PROBLEM UNITS 

        prueba.getSource().addFeatures(geojsonToFeatures(buffer));

    }
});

The error is not showing the actual kilometers and 10,000 km are not that image 1 and 100 km are not the image 2. I do not understand why this error because the buffer think this well done.

  • Buffer with 100000 units first image: Buffer with 100000 units

  • Buffer with 100 units second image Buffer with 100 units

  • Did you try setting the units to "meters", and setting the distances to 100000000 and 100000 respectively? – Gabor Farkas Jan 18 '16 at 9:37
  • Yes, I tested considerably increases the size 100000000 , 100000 and remains as the second image, I do not understand because there is still a proportion – Sergio_Az Jan 18 '16 at 9:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.