Skip to content

map.get_bounds() fails for map with GeometryCollection #1599

@blackary

Description

@blackary

Describe the bug
If you add a GeoJson with a GeometryCollection to a Map, Map.get_bounds fails

To Reproduce

import folium

m = folium.Map(location=[39.949610, -75.150282], zoom_start=16)

geojson_data = {
    "geometries": [
        {
            "coordinates": [
                [
                    [-86.1570813, 39.7567006],
                    [-86.1570169, 39.7566965],
                    [-86.1570169, 39.7566429],
                    [-86.1566146, 39.7566181],
                    [-86.1566092, 39.7566676],
                    [-86.1565288, 39.7566965],
                    [-86.1567645, 39.7572846],
                    [-86.1568399, 39.7572821],
                    [-86.156904, 39.7574413],
                    [-86.1568345, 39.7574718],
                    [-86.1568131, 39.7585688],
                    [-86.1570223, 39.7585729],
                    [-86.1570227, 39.7585614],
                    [-86.1570809, 39.7567123],
                    [-86.1570813, 39.7567006],
                ]
            ],
            "type": "Polygon",
        },
    ],
    "type": "GeometryCollection",
}
folium.GeoJson(geojson_data).add_to(m)

m.get_bounds()

Expected behavior
I expected this to return a list of two points

Environment (please complete the following information):

  • Browser [e.g. chrome, firefox]
  • Jupyter Notebook or html files?
  • Python version (check it with import sys; print(sys.version_info))
    sys.version_info(major=3, minor=9, micro=11, releaselevel='final', serial=0)
  • folium version (check it with import folium; print(folium.__version__))
    0.12.1.post1
  • branca version (check it with import branca; print(branca.__version__))
    0.5.0

Additional context
Add any other context about the problem here.

Possible solutions
List any solutions you may have come up with.

folium is maintained by volunteers. Can you help making a fix for this issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions