我想将所有要素集合转换为 Leaflet 中的几何集合

I would like to convert all feature collections to geometry collections in Leaflet

例如,toGeoJSON 函数 returns 在这里是这样的:

var geojsonFeature = {
    "type": "Feature",
    "properties": {
        "name": "Coors Field",
        "amenity": "Baseball Stadium",
        "popupContent": "This is where the Rockies play!"
    },
    "geometry": {
        "type": "Point",
        "coordinates": [-104.99404, 39.75621]
    }
};

但我想专门使用 GeometryCollection,而不是此处所述的 FeatureCollection。有什么办法可以做到吗?

有关详细信息,我想复制 中选中的答案中描述的行为,但我想改用 GeometryCollections。非常感谢。

我找到了解决方案。为了将其保存为 GeometryCollection,我使用了 djang_rest_gis 框架中描述的序列化程序。因此,我能够将我的多边形转换为 GEOSGeomtry 对象,并将其序列化。