I need to get a GeoJSON geometry of this, then use a buffer for the TURF library.
Get get data from GeoJSON turf but would not admit it in any way.
any ideas ?
This is my code:
var feature_buff = select2.getFeatures();
var geojson = new ol.format.GeoJSON();
for (var i=0;i<feature_buff.getLength();i++){
json.push(geojson.writeFeature(feature_buff.item(i)));
var obj =geojson.writeFeatures(feature_buff.item(i))
var geom = geojson.readGeometry(obj);
var buffer = turf.buffer(geom, 2000, 'kilometers')
this code fail. and this is the error:
Uncaught TypeError: (0 , ls[b.type]) is not a function
Best Answer
You don't provide the "right" content to Turf (your
geom
is not the expected content for Turf)You can also see this demo I've made months ago and this other official one.
If you don't use extensively Turf, it's also possible to use JSTS (JavaScript Topology Suite), a library to manipulate geometry in JavaScript. A demo with buffer is available at the official website.