How to convert Feature type into GeoJSON feature?
I have tried this:
var feature: FeatureLike;
var writer = new GeoJSON();
const res = writer.writeFeatureObject(feature);
console.log(res);
The GeoJSON writeFeatureObject
method only takes a Feature. If you had a RenderFeature you would need to convert it to a Feature
const res = writer.writeFeatureObject(feature instanceof RenderFeature ? toFeature(feature) : feature);
https://openlayers.org/en/latest/apidoc/module-ol_render_Feature.html#.toFeature
writeFeatureObject
method only takes a Feature. If you had a RenderFeature you would need to convert it to a Featureconst res = writer.writeFeatureObject(feature instanceof RenderFeature ? toFeature(feature) : feature);
openlayers.org/en/latest/apidoc/…