Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed multiLineString and multiPolygon issue #9533 #9540

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fixed multiLineString and multiPolygon issue #9533
  • Loading branch information
Samyak0-0 committed Nov 26, 2024
commit 3c0026e50363f5d22ca28c81d24a99727bccbd12
18 changes: 14 additions & 4 deletions src/layer/GeoJSON.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,24 @@ export function geometryToLayer(geojson, options) {
return new FeatureGroup(layers);

case 'LineString':
case 'MultiLineString':
latlngs = coordsToLatLngs(coords, geometry.type === 'LineString' ? 0 : 1, _coordsToLatLng);
latlngs = coordsToLatLngs(coords, 0, _coordsToLatLng);
return new Polyline(latlngs, options);
case 'MultiLineString':
for (i = 0, len = coords.length; i < len; i++) {
latlngs = coordsToLatLngs(coords[i], 1, _coordsToLatLng);
layers.push(new Polyline(latlngs, options));
}
return new FeatureGroup(layers);

case 'Polygon':
case 'MultiPolygon':
latlngs = coordsToLatLngs(coords, geometry.type === 'Polygon' ? 1 : 2, _coordsToLatLng);
latlngs = coordsToLatLngs(coords, 1, _coordsToLatLng);
return new Polygon(latlngs, options);
case 'MultiPolygon':
for (i = 0, len = coords.length; i < len; i++) {
latlngs = coordsToLatLngs(coords[i], 2, _coordsToLatLng);
layers.push(new Polygon(latlngs, options));
}
return new FeatureGroup(layers);

case 'GeometryCollection':
for (i = 0, len = geometry.geometries.length; i < len; i++) {
Expand Down