Open paul121 opened 2 years ago
unless using the edit behavior.
I don't need the edit behavior for my use-case because I don't need the user to manipulate geometries in the map. Instead, I'm loading a GeoJSON layer of property boundaries and asking the user to select which boundaries they want to import. I need to collect the geometries of selected features when submitting the form.
Similar to #171. Right now there is no way to return the geometry of feature(s) in a usable WKT or GeoJSON format unless using the edit behavior. You can get a simple array of coordinates for a feature using
layer.getSource().getFeatureById(id).getGeometry().getCoordinates();
which is fine forPoint
geometries but less convenient forPolygon
and other more complex geometries.Because the
edit
control already has functions for this perhaps this could be easier to expose than my request in #171. I think the only consideration is if & how we export these functions and what impact it will have on the bundle size(s). I believe this would require including the openalyersWKT
andGeoJSON
classes which could be quite large.WKT: https://github.com/farmOS/farmOS-map/blob/d3fcfc6790309775f4d242c5682822aff159eb07/src/control/Edit/Edit.js#L514-L521 GeoJson: https://github.com/farmOS/farmOS-map/blob/d3fcfc6790309775f4d242c5682822aff159eb07/src/control/Edit/Edit.js#L523-L531