Description of the limitation and why it is relevant to address
As a developer I want to have acces to the (now private) _geojson
attribute of a MapFeature
so that I can easily generate some of the GeoJSON needed for a GeoJSONView
.
I think this is relevant for the VIKTOR platform because it makes it easier to write code.
Submitter proposed design (optional)
Following on from Support multipolygons for GeoPolygon - #6 by matthijs we switched to a GeoJSONView
. We can now draw nicely draw the multipolygons. But we also show regular geometry from GeoPolylineField and GeoPolygonFields.
It would be nice to re-use the existing from_geo_
functionality of MapFeature
to generate the appropriate GeoJSON, instead of coding it ourself. Something like this:
# Idea: Add `as_geosjon()` to `MapFeature`
geojson = {"type": "FeatureCollection", "features": []}
geojson["features"].append(
MapPolygon.from_geo_polygon(
params.user_polygon,
title="Foo",
color=Color.blue(),
).as_geojson()
)
return GeoJSONResult(geojson)
Current workarounds
We now use the private _geojson
attribute, which works very nice.