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);
Matt
1,69218 silver badges24 bronze badges
asked Jun 14, 2016 at 15:24

1 Answer 1

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.

answered Jun 14, 2016 at 18:41
4
  • thank you for your replay,I tried with coordinates (40.5454,1.6544) but always without result ?? Commented Jun 15, 2016 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. Commented Jun 15, 2016 at 19:04
  • this is the correct code to display a buffer around point: Commented Jun 16, 2016 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"}); Commented Jun 16, 2016 at 10:34

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.