openlayers和turfjs(缓冲区)

时间:2017-09-01 20:10:21

标签: openlayers turfjs

我正在使用OL v4.3.2和turfjs。我想使用草皮缓冲区功能来创建基于半径的单击特征的缓冲区,但结果不准确且缓冲区非常小。所以任何人都可以帮助我?我真的很感激。

map.on('singleclick', function (e) {
var coord = e.coordinate;
var pixel = e.pixel;
console.log(coord);
map.forEachFeatureAtPixel(pixel, function (feature, layer) {
    console.log(feature);

    var p= feature.getGeometry().getCoordinates();
    var input_turf = turf.point(p);
    var buffered = turf.buffer(input_turf, 30, 'kilometers');
    var source = new ol.source.Vector();
    var format = new ol.format.GeoJSON();
    var features = format.readFeatures(buffered);
    source.addFeatures(features);
    var bufferd_layer = new ol.layer.Vector({
        source: source
    });
    map.addLayer(bufferd_layer);

},{
    hitTolerance: 15
})

});

0 个答案:

没有答案