Multiple datasets in one GeoJSONView


A fellow student and i are working with viktor for a schoolproject.
We both ran into the same problem with GeoJSONView.
Individually the datasets load in perfectly fine, but when we try to load more than one dataset we get the following error:
AttributeError: ‘str’ object has no attribute ‘_serialize’

This is the code im using:
@GeoJSONView(‘GeoJSON view’, duration_guess=1)
def get_geojson_view(self,params,**kwargs):
features = waterwegen[“features”]
for feature in features:
for point in feature[“geometry”][“coordinates”][0]:
point[1], point[0] = RDWGSConverter.from_rd_to_wgs((point[0], point[1]))
# return GeoJSONResult(waterwegen)

# @GeoJSONView('GeoJSON view', duration_guess=1)
# def get_geojson_view(self, params, **kwargs):
    features = horeca["features"]
    for feature in features:
        feature["geometry"]["coordinates"][1], feature["geometry"]["coordinates"][0] = RDWGSConverter.from_rd_to_wgs((feature["geometry"]["coordinates"][0], feature["geometry"]["coordinates"][1]))
    # return GeoJSONResult(horeca)

    return GeoJSONResult(horeca, waterwegen)

Hi Geurt, welcome to the community!

It looks like the error you are getting is thrown by the GeoJSONResult object, which expects a serializable first argument. In the GeoJSON documentation you can see that the first argument should be of type dict. You should make sure that its of type dict and contains data of serializable types such as int or str. If you are trying to add two dict objects to your GeoJSONResult object, you should combine them into a single dict.

Hope this helps!