|
17 | 17 | from branca.utilities import (_locations_tolist, _parse_size, image_to_url, iter_points, none_max, none_min) # noqa
|
18 | 18 |
|
19 | 19 | from folium.map import FeatureGroup, Icon, Layer, Marker
|
20 |
| -from folium.utilities import _parse_wms |
| 20 | +from folium.utilities import _parse_wms, get_bounds |
21 | 21 | from folium.vector_layers import PolyLine
|
22 | 22 |
|
23 | 23 | from jinja2 import Template
|
@@ -510,37 +510,13 @@ def style_data(self):
|
510 | 510 | feature.setdefault('properties', {}).setdefault('highlight', {}).update(self.highlight_function(feature)) # noqa
|
511 | 511 | return json.dumps(self.data, sort_keys=True)
|
512 | 512 |
|
513 |
| - def get_bounds(self): |
| 513 | + def _get_self_bounds(self): |
514 | 514 | """
|
515 | 515 | Computes the bounds of the object itself (not including it's children)
|
516 |
| - in the form [[lat_min, lon_min], [lat_max, lon_max]] |
| 516 | + in the form [[lat_min, lon_min], [lat_max, lon_max]]. |
517 | 517 |
|
518 | 518 | """
|
519 |
| - if not self.embed: |
520 |
| - raise ValueError('Cannot compute bounds of non-embedded GeoJSON.') |
521 |
| - |
522 |
| - if 'features' not in self.data.keys(): |
523 |
| - # Catch case when GeoJSON is just a single Feature or a geometry. |
524 |
| - if not (isinstance(self.data, dict) and 'geometry' in self.data.keys()): # noqa |
525 |
| - # Catch case when GeoJSON is just a geometry. |
526 |
| - self.data = {'type': 'Feature', 'geometry': self.data} |
527 |
| - self.data = {'type': 'FeatureCollection', 'features': [self.data]} |
528 |
| - |
529 |
| - bounds = [[None, None], [None, None]] |
530 |
| - for feature in self.data['features']: |
531 |
| - for point in iter_points(feature.get('geometry', {}).get('coordinates', {})): # noqa |
532 |
| - bounds = [ |
533 |
| - [ |
534 |
| - none_min(bounds[0][0], point[1]), |
535 |
| - none_min(bounds[0][1], point[0]), |
536 |
| - ], |
537 |
| - [ |
538 |
| - none_max(bounds[1][0], point[1]), |
539 |
| - none_max(bounds[1][1], point[0]), |
540 |
| - ], |
541 |
| - ] |
542 |
| - return bounds |
543 |
| - |
| 519 | + return get_bounds(self.data, lonlat=True) |
544 | 520 |
|
545 | 521 | class TopoJson(Layer):
|
546 | 522 | """
|
|
0 commit comments