[GIS] Create buffer around point with Turf

javascriptleafletturfweb-mapping

This code is not working and I don't know why?

function getlatlong(b,d){
   return b,d;
}

function buffer(feature){
    var point = {
    type: 'Feature',
    geometry: {
    type: 'Point',
    coordinates: getlatlong(feature.properties.x,feature.properties.y)
  },
    properties: {}
};
    var unit = 'meters';
    var buffered = turf.buffer(point, 10, unit);
    var result = turf.featurecollection([buffered, point]);

    L.geoJson(buffered).addTo(map);

Best Answer

It might have to do with your getlatlong() function. I would try to troubleshoot by first replacing coordinates: getlatlong(feature.properties.x, feature.properties.y) with [1,1] or some other simple known X and Y. If that works then your issue is with this. If not you've ruled that out.

I don't see anything misspelled or punctuation missing so after that I can't see what would stop it. An error message would help at this point.