widget_to_marker 包使开发者能够将任何 Flutter 小部件转换为 BitmapDescriptor,从而通过 google_maps_flutter 插件将自定义设计的小部件用作 Google 地图标记上的图标。这对于创建视觉丰富、动态的标记非常有用,这些标记超越了标准图标。该包支持 Android、iOS 和 Web 平台,确保跨平台的一致性。它简化了在地图上直接渲染复杂 UI 元素(如头像、徽章或自定义形状)的过程。
适合场景
带有动态内容的自定义地图标记
在地图上显示用户头像
创建品牌或主题标记
实时标记更新与动画小部件
在地图上叠加交互式用户界面元素
主要特点
将任何 Flutter widget 转换为 BitmapDescriptor
支持 Android、iOS 和 Web
与 google_maps_flutter 的简单集成
复杂控件的高效渲染
跨平台兼容性
适合对象
开发交互式地图的开发者
需要品牌化或个性化标记的应用程序
使用动态或动画标记内容的项目
优先考虑跨平台的视觉一致性
寻找静态图标图像替代方案的用户
使用建议
复杂或频繁更新的部件对性能的影响
位图生成可能带来的内存开销
需要妥善处理生成的描述符
仅限静态快照(非交互式小部件)
可能需要针对高频更新进行优化
原始 README
以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。
Features
When using Google Maps, we always have a problem with adding a marker on the map, and the available tools were either drawing the marker through canvas path or using an image, but the problem is if we want to add words or data or add custom edit to this marker, but this package has solved the problem and now you can use any widget in flutter as a marker for google map !
using the .toBitmapDescriptor() function on the widget to use it as a marker icon!