Leaflet/Leaflet — pull request #1462 by jfirebaugh (2013-02-26 23:12:51+00:00)
Title: Add #toGeoJSON to various layer types (#712)

Two shortcomings of this approach:

1. Features and FeatureCollections aren't round tripped. `L.GeoJSON.geometryToLayer`
discards feature properties and I'm not seeing a clear way to keep those around for
reserialization.

2. MultiPoints aren't round tripped. `L.GeoJSON.geometryToLayer` creates a FeatureGroup
of Markers when it encounters a MultiPoint, but my implementation of
`FeatureGroup#toGeoJSON` always creates a GeometryCollection.

@jfgirard's implementation in #712 contains a heuristic: if converting each layer
in a FeatureGroup to GeoJSON produces only Points, it returns a MultiPoint, otherwise
it returns a GeometryCollection. I don't like this solution, because it results in
the opposite problem: a GeometryCollection containing only Points can't be round tripped.

Instead I think Leaflet should have a dedicated MultiMarker class in the style of
MultiPolyline and MultiPolygon. But implementing that is tricky, because it needs to
support L.GeoJSON's `pointToLayer` option.