34
34
)
35
35
from branca .utilities import color_brewer
36
36
37
- import folium .map
38
37
from folium .elements import JSCSSMixin
39
38
from folium .folium import Map
39
+ from folium .map import FeatureGroup , Icon , Layer , Marker , Popup , Tooltip
40
40
from folium .template import Template
41
41
from folium .utilities import (
42
42
JsCode ,
60
60
from folium .vector_layers import Circle , CircleMarker , PolyLine , path_options
61
61
62
62
63
- class RegularPolygonMarker (JSCSSMixin , folium . map . Marker ):
63
+ class RegularPolygonMarker (JSCSSMixin , Marker ):
64
64
"""
65
65
Custom markers using the Leaflet Data Vis Framework.
66
66
@@ -109,8 +109,8 @@ def __init__(
109
109
number_of_sides : int = 4 ,
110
110
rotation : int = 0 ,
111
111
radius : int = 15 ,
112
- popup : Union [folium . map . Popup , str , None ] = None ,
113
- tooltip : Union [folium . map . Tooltip , str , None ] = None ,
112
+ popup : Union [Popup , str , None ] = None ,
113
+ tooltip : Union [Tooltip , str , None ] = None ,
114
114
** kwargs : TypePathOptions ,
115
115
):
116
116
super ().__init__ (location , popup = popup , tooltip = tooltip )
@@ -310,7 +310,7 @@ def __init__(
310
310
def render (self , ** kwargs ):
311
311
"""Renders the HTML representation of the element."""
312
312
parent = self ._parent
313
- if not isinstance (parent , (Figure , Div , folium . map . Popup )):
313
+ if not isinstance (parent , (Figure , Div , Popup )):
314
314
raise TypeError (
315
315
"VegaLite elements can only be added to a Figure, Div, or Popup"
316
316
)
@@ -480,7 +480,7 @@ def _embed_vegalite_v1(self, figure: Figure, parent: TypeContainer) -> None:
480
480
)
481
481
482
482
483
- class GeoJson (folium . map . Layer ):
483
+ class GeoJson (Layer ):
484
484
"""
485
485
Creates a GeoJson object for plotting into a Map.
486
486
@@ -696,7 +696,7 @@ def __init__(
696
696
control : bool = True ,
697
697
show : bool = True ,
698
698
smooth_factor : Optional [float ] = None ,
699
- tooltip : Union [str , folium . map . Tooltip , "GeoJsonTooltip" , None ] = None ,
699
+ tooltip : Union [str , Tooltip , "GeoJsonTooltip" , None ] = None ,
700
700
embed : bool = True ,
701
701
popup : Optional ["GeoJsonPopup" ] = None ,
702
702
zoom_on_click : bool = False ,
@@ -715,7 +715,7 @@ def __init__(
715
715
self .highlight = highlight_function is not None
716
716
self .zoom_on_click = zoom_on_click
717
717
if marker :
718
- if not isinstance (marker , (Circle , CircleMarker , folium . map . Marker )):
718
+ if not isinstance (marker , (Circle , CircleMarker , Marker )):
719
719
raise TypeError (
720
720
"Only Marker, Circle, and CircleMarker are supported as GeoJson marker types."
721
721
)
@@ -744,11 +744,11 @@ def __init__(
744
744
self .highlight_map : dict = {}
745
745
self .feature_identifier = self .find_identifier ()
746
746
747
- if isinstance (tooltip , (GeoJsonTooltip , folium . map . Tooltip )):
747
+ if isinstance (tooltip , (GeoJsonTooltip , Tooltip )):
748
748
self .add_child (tooltip )
749
749
elif tooltip is not None :
750
- self .add_child (folium . map . Tooltip (tooltip ))
751
- if isinstance (popup , (GeoJsonPopup , folium . map . Popup )):
750
+ self .add_child (Tooltip (tooltip ))
751
+ if isinstance (popup , (GeoJsonPopup , Popup )):
752
752
self .add_child (popup )
753
753
754
754
def process_data (self , data : Any ) -> dict :
@@ -939,7 +939,7 @@ def _set_default_key(mapping: TypeStyleMapping) -> None:
939
939
del mapping [key_longest ]
940
940
941
941
942
- class TopoJson (JSCSSMixin , folium . map . Layer ):
942
+ class TopoJson (JSCSSMixin , Layer ):
943
943
"""
944
944
Creates a TopoJson object for plotting into a Map.
945
945
@@ -1034,7 +1034,7 @@ def __init__(
1034
1034
control : bool = True ,
1035
1035
show : bool = True ,
1036
1036
smooth_factor : Optional [float ] = None ,
1037
- tooltip : Union [str , folium . map . Tooltip , None ] = None ,
1037
+ tooltip : Union [str , Tooltip , None ] = None ,
1038
1038
):
1039
1039
super ().__init__ (name = name , overlay = overlay , control = control , show = show )
1040
1040
self ._name = "TopoJson"
@@ -1058,10 +1058,10 @@ def __init__(
1058
1058
1059
1059
self .smooth_factor = smooth_factor
1060
1060
1061
- if isinstance (tooltip , (GeoJsonTooltip , folium . map . Tooltip )):
1061
+ if isinstance (tooltip , (GeoJsonTooltip , Tooltip )):
1062
1062
self .add_child (tooltip )
1063
1063
elif tooltip is not None :
1064
- self .add_child (folium . map . Tooltip (tooltip ))
1064
+ self .add_child (Tooltip (tooltip ))
1065
1065
1066
1066
def style_data (self ) -> None :
1067
1067
"""Applies self.style_function to each feature of self.data."""
@@ -1408,7 +1408,7 @@ def __init__(
1408
1408
self .popup_options = kwargs
1409
1409
1410
1410
1411
- class Choropleth (folium . map . FeatureGroup ):
1411
+ class Choropleth (FeatureGroup ):
1412
1412
"""Apply a GeoJSON overlay to the map.
1413
1413
1414
1414
Plot a GeoJSON overlay on the base map. There is no requirement
@@ -1886,7 +1886,7 @@ def __init__(self, format_str: Optional[str] = None, alert: bool = True):
1886
1886
self .alert = alert
1887
1887
1888
1888
1889
- class CustomIcon (folium . map . Icon ):
1889
+ class CustomIcon (Icon ):
1890
1890
"""
1891
1891
Create a custom icon, based on an image.
1892
1892
@@ -1939,7 +1939,7 @@ def __init__(
1939
1939
shadow_anchor : Optional [Tuple [int , int ]] = None ,
1940
1940
popup_anchor : Optional [Tuple [int , int ]] = None ,
1941
1941
):
1942
- super (folium . map . Icon , self ).__init__ ()
1942
+ super (Icon , self ).__init__ ()
1943
1943
self ._name = "CustomIcon"
1944
1944
self .options = remove_empty (
1945
1945
icon_url = image_to_url (icon_image ),
@@ -1952,7 +1952,7 @@ def __init__(
1952
1952
)
1953
1953
1954
1954
1955
- class ColorLine (folium . map . FeatureGroup ):
1955
+ class ColorLine (FeatureGroup ):
1956
1956
"""
1957
1957
Draw data on a map with specified colors.
1958
1958
0 commit comments