23
23
)
24
24
from branca .utilities import color_brewer
25
25
26
- import folium .map
27
26
from folium .elements import JSCSSMixin
28
27
from folium .folium import Map
28
+ from folium .map import FeatureGroup , Icon , Layer , Marker , Popup , Tooltip
29
29
from folium .template import Template
30
30
from folium .utilities import (
31
31
TypeBoundsReturn ,
47
47
from folium .vector_layers import Circle , CircleMarker , PolyLine , path_options
48
48
49
49
50
- class RegularPolygonMarker (JSCSSMixin , folium . map . Marker ):
50
+ class RegularPolygonMarker (JSCSSMixin , Marker ):
51
51
"""
52
52
Custom markers using the Leaflet Data Vis Framework.
53
53
@@ -96,8 +96,8 @@ def __init__(
96
96
number_of_sides : int = 4 ,
97
97
rotation : int = 0 ,
98
98
radius : int = 15 ,
99
- popup : Union [folium . map . Popup , str , None ] = None ,
100
- tooltip : Union [folium . map . Tooltip , str , None ] = None ,
99
+ popup : Union [Popup , str , None ] = None ,
100
+ tooltip : Union [Tooltip , str , None ] = None ,
101
101
** kwargs : TypePathOptions ,
102
102
):
103
103
super ().__init__ (location , popup = popup , tooltip = tooltip )
@@ -297,7 +297,7 @@ def __init__(
297
297
def render (self , ** kwargs ):
298
298
"""Renders the HTML representation of the element."""
299
299
parent = self ._parent
300
- if not isinstance (parent , (Figure , Div , folium . map . Popup )):
300
+ if not isinstance (parent , (Figure , Div , Popup )):
301
301
raise TypeError (
302
302
"VegaLite elements can only be added to a Figure, Div, or Popup"
303
303
)
@@ -467,7 +467,7 @@ def _embed_vegalite_v1(self, figure: Figure, parent: TypeContainer) -> None:
467
467
)
468
468
469
469
470
- class GeoJson (folium . map . Layer ):
470
+ class GeoJson (Layer ):
471
471
"""
472
472
Creates a GeoJson object for plotting into a Map.
473
473
@@ -675,11 +675,11 @@ def __init__(
675
675
control : bool = True ,
676
676
show : bool = True ,
677
677
smooth_factor : Optional [float ] = None ,
678
- tooltip : Union [str , folium . map . Tooltip , "GeoJsonTooltip" , None ] = None ,
678
+ tooltip : Union [str , Tooltip , "GeoJsonTooltip" , None ] = None ,
679
679
embed : bool = True ,
680
680
popup : Optional ["GeoJsonPopup" ] = None ,
681
681
zoom_on_click : bool = False ,
682
- marker : Union [Circle , CircleMarker , folium . map . Marker , None ] = None ,
682
+ marker : Union [Circle , CircleMarker , Marker , None ] = None ,
683
683
** kwargs : Any ,
684
684
):
685
685
super ().__init__ (name = name , overlay = overlay , control = control , show = show )
@@ -693,7 +693,7 @@ def __init__(
693
693
self .highlight = highlight_function is not None
694
694
self .zoom_on_click = zoom_on_click
695
695
if marker :
696
- if not isinstance (marker , (Circle , CircleMarker , folium . map . Marker )):
696
+ if not isinstance (marker , (Circle , CircleMarker , Marker )):
697
697
raise TypeError (
698
698
"Only Marker, Circle, and CircleMarker are supported as GeoJson marker types."
699
699
)
@@ -721,11 +721,11 @@ def __init__(
721
721
self .highlight_map : dict = {}
722
722
self .feature_identifier = self .find_identifier ()
723
723
724
- if isinstance (tooltip , (GeoJsonTooltip , folium . map . Tooltip )):
724
+ if isinstance (tooltip , (GeoJsonTooltip , Tooltip )):
725
725
self .add_child (tooltip )
726
726
elif tooltip is not None :
727
- self .add_child (folium . map . Tooltip (tooltip ))
728
- if isinstance (popup , (GeoJsonPopup , folium . map . Popup )):
727
+ self .add_child (Tooltip (tooltip ))
728
+ if isinstance (popup , (GeoJsonPopup , Popup )):
729
729
self .add_child (popup )
730
730
731
731
def process_data (self , data : Any ) -> dict :
@@ -916,7 +916,7 @@ def _set_default_key(mapping: TypeStyleMapping) -> None:
916
916
del mapping [key_longest ]
917
917
918
918
919
- class TopoJson (JSCSSMixin , folium . map . Layer ):
919
+ class TopoJson (JSCSSMixin , Layer ):
920
920
"""
921
921
Creates a TopoJson object for plotting into a Map.
922
922
@@ -1011,7 +1011,7 @@ def __init__(
1011
1011
control : bool = True ,
1012
1012
show : bool = True ,
1013
1013
smooth_factor : Optional [float ] = None ,
1014
- tooltip : Union [str , folium . map . Tooltip , None ] = None ,
1014
+ tooltip : Union [str , Tooltip , None ] = None ,
1015
1015
):
1016
1016
super ().__init__ (name = name , overlay = overlay , control = control , show = show )
1017
1017
self ._name = "TopoJson"
@@ -1035,10 +1035,10 @@ def __init__(
1035
1035
1036
1036
self .smooth_factor = smooth_factor
1037
1037
1038
- if isinstance (tooltip , (GeoJsonTooltip , folium . map . Tooltip )):
1038
+ if isinstance (tooltip , (GeoJsonTooltip , Tooltip )):
1039
1039
self .add_child (tooltip )
1040
1040
elif tooltip is not None :
1041
- self .add_child (folium . map . Tooltip (tooltip ))
1041
+ self .add_child (Tooltip (tooltip ))
1042
1042
1043
1043
def style_data (self ) -> None :
1044
1044
"""Applies self.style_function to each feature of self.data."""
@@ -1377,7 +1377,7 @@ def __init__(
1377
1377
self .popup_options = kwargs
1378
1378
1379
1379
1380
- class Choropleth (folium . map . FeatureGroup ):
1380
+ class Choropleth (FeatureGroup ):
1381
1381
"""Apply a GeoJSON overlay to the map.
1382
1382
1383
1383
Plot a GeoJSON overlay on the base map. There is no requirement
@@ -1855,7 +1855,7 @@ def __init__(self, format_str: Optional[str] = None, alert: bool = True):
1855
1855
self .alert = alert
1856
1856
1857
1857
1858
- class CustomIcon (folium . map . Icon ):
1858
+ class CustomIcon (Icon ):
1859
1859
"""
1860
1860
Create a custom icon, based on an image.
1861
1861
@@ -1908,7 +1908,7 @@ def __init__(
1908
1908
shadow_anchor : Optional [Tuple [int , int ]] = None ,
1909
1909
popup_anchor : Optional [Tuple [int , int ]] = None ,
1910
1910
):
1911
- super (folium . map . Icon , self ).__init__ ()
1911
+ super (Icon , self ).__init__ ()
1912
1912
self ._name = "CustomIcon"
1913
1913
self .options = remove_empty (
1914
1914
icon_url = image_to_url (icon_image ),
@@ -1921,7 +1921,7 @@ def __init__(
1921
1921
)
1922
1922
1923
1923
1924
- class ColorLine (folium . map . FeatureGroup ):
1924
+ class ColorLine (FeatureGroup ):
1925
1925
"""
1926
1926
Draw data on a map with specified colors.
1927
1927
0 commit comments