GeoJSON.js (Leaflet-1.8.0) | : | GeoJSON.js (Leaflet-1.9.0) | ||
---|---|---|---|---|
skipping to change at line 208 | skipping to change at line 208 | |||
latlngs = coordsToLatLngs(coords, geometry.type === 'LineString' ? 0 : 1, _coordsToLatLng); | latlngs = coordsToLatLngs(coords, geometry.type === 'LineString' ? 0 : 1, _coordsToLatLng); | |||
return new Polyline(latlngs, options); | return new Polyline(latlngs, options); | |||
case 'Polygon': | case 'Polygon': | |||
case 'MultiPolygon': | case 'MultiPolygon': | |||
latlngs = coordsToLatLngs(coords, geometry.type === 'Polygon' ? 1 : 2, _coordsToLatLng); | latlngs = coordsToLatLngs(coords, geometry.type === 'Polygon' ? 1 : 2, _coordsToLatLng); | |||
return new Polygon(latlngs, options); | return new Polygon(latlngs, options); | |||
case 'GeometryCollection': | case 'GeometryCollection': | |||
for (i = 0, len = geometry.geometries.length; i < len; i++) { | for (i = 0, len = geometry.geometries.length; i < len; i++) { | |||
var layer = geometryToLayer({ | var geoLayer = geometryToLayer({ | |||
geometry: geometry.geometries[i], | geometry: geometry.geometries[i], | |||
type: 'Feature', | type: 'Feature', | |||
properties: geojson.properties | properties: geojson.properties | |||
}, options); | }, options); | |||
if (layer) { | if (geoLayer) { | |||
layers.push(layer); | 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); | return new FeatureGroup(layers); | |||
default: | default: | |||
throw new Error('Invalid GeoJSON object.'); | throw new Error('Invalid GeoJSON object.'); | |||
} | } | |||
} | } | |||
function _pointToLayer(pointToLayerFn, geojson, latlng, options) { | function _pointToLayer(pointToLayerFn, geojson, latlng, options) { | |||
skipping to change at line 274 | skipping to change at line 284 | |||
} | } | |||
// @function latLngsToCoords(latlngs: Array, levelsDeep?: Number, closed?: Boole an, precision?: Number|false): Array | // @function latLngsToCoords(latlngs: Array, levelsDeep?: Number, closed?: Boole an, precision?: Number|false): Array | |||
// Reverse of [`coordsToLatLngs`](#geojson-coordstolatlngs) | // Reverse of [`coordsToLatLngs`](#geojson-coordstolatlngs) | |||
// `closed` determines whether the first point should be appended to the end of the array to close the feature, only used when `levelsDeep` is 0. False by defau lt. | // `closed` determines whether the first point should be appended to the end of the array to close the feature, only used when `levelsDeep` is 0. False by defau lt. | |||
// Coordinates values are rounded with [`formatNum`](#util-formatnum) function. | // Coordinates values are rounded with [`formatNum`](#util-formatnum) function. | |||
export function latLngsToCoords(latlngs, levelsDeep, closed, precision) { | export function latLngsToCoords(latlngs, levelsDeep, closed, precision) { | |||
var coords = []; | var coords = []; | |||
for (var i = 0, len = latlngs.length; i < len; i++) { | for (var i = 0, len = latlngs.length; i < len; i++) { | |||
// Check for flat arrays required to ensure unbalanced arrays are correctly converted in recursion | ||||
coords.push(levelsDeep ? | coords.push(levelsDeep ? | |||
latLngsToCoords(latlngs[i], levelsDeep - 1, closed, preci sion) : | latLngsToCoords(latlngs[i], LineUtil.isFlat(latlngs[i]) ? 0 : levelsDeep - 1, closed, precision) : | |||
latLngToCoords(latlngs[i], precision)); | latLngToCoords(latlngs[i], precision)); | |||
} | } | |||
if (!levelsDeep && closed) { | if (!levelsDeep && closed) { | |||
coords.push(coords[0]); | coords.push(coords[0]); | |||
} | } | |||
return coords; | return coords; | |||
} | } | |||
End of changes. 4 change blocks. | ||||
4 lines changed or deleted | 16 lines changed or added |