Fit the map to contain a bounding box with the maximum zoom level possible. Parameters ---------- bounds: list of (latitude, longitude) points Bounding box specified as two points [southwest, northeast] padding_top_left: (x, y) point, default None Padding in the
| 648 | |
| 649 | |
| 650 | class FitBounds(MacroElement): |
| 651 | """Fit the map to contain a bounding box with the |
| 652 | maximum zoom level possible. |
| 653 | |
| 654 | Parameters |
| 655 | ---------- |
| 656 | bounds: list of (latitude, longitude) points |
| 657 | Bounding box specified as two points [southwest, northeast] |
| 658 | padding_top_left: (x, y) point, default None |
| 659 | Padding in the top left corner. Useful if some elements in |
| 660 | the corner, such as controls, might obscure objects you're zooming |
| 661 | to. |
| 662 | padding_bottom_right: (x, y) point, default None |
| 663 | Padding in the bottom right corner. |
| 664 | padding: (x, y) point, default None |
| 665 | Equivalent to setting both top left and bottom right padding to |
| 666 | the same value. |
| 667 | max_zoom: int, default None |
| 668 | Maximum zoom to be used. |
| 669 | """ |
| 670 | |
| 671 | _template = Template( |
| 672 | """ |
| 673 | {% macro script(this, kwargs) %} |
| 674 | {{ this._parent.get_name() }}.fitBounds( |
| 675 | {{ this.bounds|tojson }}, |
| 676 | {{ this.options|tojson }} |
| 677 | ); |
| 678 | {% endmacro %} |
| 679 | """ |
| 680 | ) |
| 681 | |
| 682 | def __init__( |
| 683 | self, |
| 684 | bounds: TypeBounds, |
| 685 | padding_top_left: Optional[Sequence[float]] = None, |
| 686 | padding_bottom_right: Optional[Sequence[float]] = None, |
| 687 | padding: Optional[Sequence[float]] = None, |
| 688 | max_zoom: Optional[int] = None, |
| 689 | ): |
| 690 | super().__init__() |
| 691 | self._name = "FitBounds" |
| 692 | self.bounds = bounds |
| 693 | self.options = parse_options( |
| 694 | max_zoom=max_zoom, |
| 695 | padding_top_left=padding_top_left, |
| 696 | padding_bottom_right=padding_bottom_right, |
| 697 | padding=padding, |
| 698 | ) |
| 699 | |
| 700 | |
| 701 | class FitOverlays(MacroElement): |