(
self,
data: Any,
object_path: str,
style_function: Optional[Callable] = None,
name: Optional[str] = None,
overlay: bool = True,
control: bool = True,
show: bool = True,
smooth_factor: Optional[float] = None,
tooltip: Union[str, Tooltip, None] = None,
)
| 1025 | ] |
| 1026 | |
| 1027 | def __init__( |
| 1028 | self, |
| 1029 | data: Any, |
| 1030 | object_path: str, |
| 1031 | style_function: Optional[Callable] = None, |
| 1032 | name: Optional[str] = None, |
| 1033 | overlay: bool = True, |
| 1034 | control: bool = True, |
| 1035 | show: bool = True, |
| 1036 | smooth_factor: Optional[float] = None, |
| 1037 | tooltip: Union[str, Tooltip, None] = None, |
| 1038 | ): |
| 1039 | super().__init__(name=name, overlay=overlay, control=control, show=show) |
| 1040 | self._name = "TopoJson" |
| 1041 | |
| 1042 | if "read" in dir(data): |
| 1043 | self.embed = True |
| 1044 | self.data = json.load(data) |
| 1045 | elif type(data) is dict: |
| 1046 | self.embed = True |
| 1047 | self.data = data |
| 1048 | else: |
| 1049 | self.embed = False |
| 1050 | self.data = data |
| 1051 | |
| 1052 | self.object_path = object_path |
| 1053 | self._safe_object_path = javascript_identifier_path_to_array_notation( |
| 1054 | object_path |
| 1055 | ) |
| 1056 | |
| 1057 | self.style_function = style_function or (lambda x: {}) |
| 1058 | |
| 1059 | self.smooth_factor = smooth_factor |
| 1060 | |
| 1061 | if isinstance(tooltip, (GeoJsonTooltip, Tooltip)): |
| 1062 | self.add_child(tooltip) |
| 1063 | elif tooltip is not None: |
| 1064 | self.add_child(Tooltip(tooltip)) |
| 1065 | |
| 1066 | def style_data(self) -> None: |
| 1067 | """Applies self.style_function to each feature of self.data.""" |
nothing calls this directly
no test coverage detected