2

leaflet use FeatureGroup() for edit. and I want to save data use toGeoJSON.but circle,marker... have point info only.

{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[118.49561691284181,31.87595414652557]}},{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[118.5268591952,31.848500597]}}]}

I need save more info.how?

4

1 回答 1

1

严格来说,将这种数据“保存到 GeoJSON”是不可能的,因为 GeoJSON 不支持圆圈。

GeoJSON 支持以下几何类型:Point、LineString、Polygon、MultiPoint、MultiLineString、MultiPolygon 和 GeometryCollection。

旧的 2008 年 GeoJSON 规范没有说明圆圈http://geojson.org/geojson-spec.html 和新的(2016 年 8 月)https://www.rfc-editor.org/rfc/rfc7946

如果您想保存一个点及其半径来表示一个圆,您需要制作自己的格式,但这当然不能与传单的 geojson 图层组一起使用。

编辑:似乎有些人已经走上了这条路,所以你可能想看看这个: https ://github.com/Leaflet/Leaflet.draw/issues/390

他们将半径保存在propertiesGeoJSON 中并扩展了 GeoJSON 图层组以使用它。有点hacky,geojson规范付诸东流,但它似乎完成了你想要的。

另一种可能性是将您的圆转换为具有可接受数量节点的多边形,然后将该多边形保存在 GeoJSON 中。

于 2016-11-25T21:53:26.517 回答