1

我正在使用 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
})

});

4

0 回答 0