L.GeoJSON.asFeature should pass through FeatureCollections (#5049)
* L.GeoJSON.asFeature should pass through FeatureCollections * Add unit test to verify FeatureCollection toGeoJSON
This commit is contained in:
parent
d0d699bfa4
commit
fd78560036
@ -68,4 +68,28 @@
|
|||||||
}, ctx);
|
}, ctx);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("#toGeoJSON", function () {
|
||||||
|
it('should return valid GeoJSON for a layer with a FeatureCollection', function () {
|
||||||
|
var geoJSON = {
|
||||||
|
"type":"FeatureCollection",
|
||||||
|
"features":[
|
||||||
|
{
|
||||||
|
"type":"Feature",
|
||||||
|
"properties":{},
|
||||||
|
"geometry": {
|
||||||
|
"type":"Point",
|
||||||
|
"coordinates": [78.3984375, 56.9449741808516]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
var layerGroup = L.layerGroup();
|
||||||
|
var layer = L.geoJSON(geoJSON);
|
||||||
|
layerGroup.addLayer(layer);
|
||||||
|
|
||||||
|
L.geoJson(layerGroup.toGeoJSON());
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -264,7 +264,7 @@ L.extend(L.GeoJSON, {
|
|||||||
// @function asFeature(geojson: Object): Object
|
// @function asFeature(geojson: Object): Object
|
||||||
// Normalize GeoJSON geometries/features into GeoJSON features.
|
// Normalize GeoJSON geometries/features into GeoJSON features.
|
||||||
asFeature: function (geojson) {
|
asFeature: function (geojson) {
|
||||||
if (geojson.type === 'Feature') {
|
if (geojson.type === 'Feature' || geojson.type === 'FeatureCollection') {
|
||||||
return geojson;
|
return geojson;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user