mirror of
https://github.com/Leaflet/Leaflet.git
synced 2025-08-16 16:45:22 +00:00
Add FeatureCollection to geometryToLayer (#8163)
This commit is contained in:
@ -571,6 +571,19 @@ describe("L.GeoJSON functions", function () {
|
||||
]
|
||||
};
|
||||
|
||||
var featureCollection = {
|
||||
type: "FeatureCollection",
|
||||
features: [
|
||||
{
|
||||
type: "Feature",
|
||||
geometry: {
|
||||
type: "Point",
|
||||
coordinates: [0, 0]
|
||||
}
|
||||
},
|
||||
]
|
||||
};
|
||||
|
||||
function customPointToLayer(geojsonPoint, latLng) {
|
||||
return L.circle(latLng, {
|
||||
radius: geojsonPoint.properties.radius
|
||||
@ -588,7 +601,8 @@ describe("L.GeoJSON functions", function () {
|
||||
[multiPoint, L.FeatureGroup],
|
||||
[multiLine, L.Polyline],
|
||||
[multiPolygon, L.Polygon],
|
||||
[geometryCollection, L.FeatureGroup]
|
||||
[geometryCollection, L.FeatureGroup],
|
||||
[featureCollection, L.FeatureGroup]
|
||||
].forEach(function (item) {
|
||||
var geometry = item[0], expectedType = item[1];
|
||||
|
||||
|
@ -206,14 +206,24 @@ export function geometryToLayer(geojson, options) {
|
||||
|
||||
case 'GeometryCollection':
|
||||
for (i = 0, len = geometry.geometries.length; i < len; i++) {
|
||||
var layer = geometryToLayer({
|
||||
var geoLayer = geometryToLayer({
|
||||
geometry: geometry.geometries[i],
|
||||
type: 'Feature',
|
||||
properties: geojson.properties
|
||||
}, options);
|
||||
|
||||
if (layer) {
|
||||
layers.push(layer);
|
||||
if (geoLayer) {
|
||||
layers.push(geoLayer);
|
||||
}
|
||||
}
|
||||
return new FeatureGroup(layers);
|
||||
|
||||
case 'FeatureCollection':
|
||||
for (i = 0, len = geometry.features.length; i < len; i++) {
|
||||
var featureLayer = geometryToLayer(geometry.features[i], options);
|
||||
|
||||
if (featureLayer) {
|
||||
layers.push(featureLayer);
|
||||
}
|
||||
}
|
||||
return new FeatureGroup(layers);
|
||||
|
Reference in New Issue
Block a user