主题
PolygonMarker 继承自: ft.BaseControl
A marker for the PolygonLayer.
属性
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
coordinates | list[MapLatitudeLongitude] | required | The points for the outline of this polygon. |
label | Optional[str] | None | An optional label for this polygon. Note: Specifying a label will reduce performance, as the internal canvas must be drawn to and 'saved' more frequently to ensure the proper stacking order is maintained. This can be avoided, potentially at the expense of appearance, by setting draw_labels_last. |
label_text_style | Optional[ft.TextStyle] | None | The text style for the label. |
border_color | ft.ColorValue | ft.Colors.GREEN | The color of the border outline. |
color | ft.ColorValue | ft.Colors.GREEN | The color of the polygon. |
border_stroke_width | ft.Number | 0.0 | The width of the border outline. Raises: ValueError: If it is less than 0.0. |
disable_holes_border | bool | False | Whether holes should have borders. |
rotate_label | bool | False | Whether to rotate the label counter to the camera's rotation, to ensure it remains upright. |
stroke_cap | ft.StrokeCap | ft.StrokeCap.ROUND | Style to use for line endings. |
stroke_join | ft.StrokeJoin | ft.StrokeJoin.ROUND | Style to use for line segment joins. |
visible | bool | True | Whether this marker is rendered on the map. |
data | Any | skip_ | 任意类型的自定义数据。 |
key | Optional['KeyValue'] | None | 用于在更新之间保持控件身份稳定的 key。 |
只读属性
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
parent | Optional['BaseControl'] | — | The direct ancestor(parent) of this control. It defaults to None and will only have a value when this control is mounted (added to the page tree). Page 控件(树的根)为例外 —— 它始终 parent=None。 |
page | 'Page' | — | 此控件所属的页面。 |
方法
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
before_update | — | — | — |
is_isolated | — | — | Return whether this control is marked as isolated. 被隔离的控件不会参与父级驱动的更新遍历,需要自行管理更新边界。 |
init | — | — | Called after control instance initialization and before the first build / update cycle. 可重写此钩子执行依赖于已初始化字段的轻量设置。 不要在这里调用 update()。 |
build | — | — | 在控件初始化期间调用一次,用于定义其子控件。 page 属性在此方法中可用。 |
before_event | — | — | 在事件处理器执行前拦截事件。 返回 False 取消分发,返回 True 或 None 则继续正常的事件处理。 |
did_mount | — | — | 在控件挂载到页面树之后调用。 可重写以启动需要已挂载页面的资源,例如订阅、定时器或服务监听。 |
will_unmount | — | — | 在控件从页面树移除之前调用。 可重写以释放 did_mount() 中创建的资源,例如订阅、定时器或外部句柄。 |
get_data_channel | — | — | Resolve the [DataChannel] allocated on the Dart side for this widget. Pattern: on_data_channel_open: Optional[ft.EventHandler[DataChannelOpenEvent]] = None def init(self): self.on_data_channel_open = self._on_open def _on_open(self, e): self._channel = self.get_data_channel(e.channel_id) Idempotent — the underlying Connection caches DataChannels by id, so repeated calls return the same instance. No error path: the id always comes from a framework-fired event, so by the time this runs the channel exists on both sides. |
update | None | — | 请求更新该控件的 UI。 在修改控件状态或属性后调用。 控件必须已挂载到页面,并且未被冻结。 |