0

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);
1

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.

  • thank you for your replay,I tried with coordinates (40.5454,1.6544) but always without result ?? – user28253 Jun 15 '16 at 7:26
  • Open the console feature for your browser and trace any errors and add them to your question. If there aren't any then add that fact to your original question and maybe someone with a better eye can see the issue. – Barrett Jun 15 '16 at 19:04
  • this is the correct code to display a buffer around point: – user28253 Jun 16 '16 at 10:31
  • var pt = { "type": "Feature", "properties": {}, "geometry": { "type": "Point", "coordinates": [2.17279,44.04812] } }; var b = turf.buffer(pt,500,"meters"); var bufferLayer500 =L.geoJson(b).addTo(map); bufferLayer500.setStyle({color: "#FFFF00"}); – user28253 Jun 16 '16 at 10:34

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.