HarmonyOS 地图组件如何添加自定义UI

HarmonyOS
2025-01-10 08:03:09
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
zbw_apple

参考示例:

build() {
  Stack() {
    Column() {
      MapComponent({
        mapOptions: this.mapOptions,
        mapCallback: this.callback,
        // 自定义信息窗
        customInfoWindow: this.customInfoWindow
      })
        .width('100%')
        .height('100%');
    }.width('100%')
  }.height('100%')
}
// 自定义信息窗BuilderParam
@BuilderParam customInfoWindow: ($$: map.MarkerDelegate) => void = this.customInfoWindowBuilder;
// 自定义信息窗Builder
@Builder
customInfoWindowBuilder($$: map.MarkerDelegate) {
  if ($$.marker) {
    Text($$.marker.getTitle())
      .width("50%")
      .height(50)
      .backgroundColor(Color.Green)
      .textAlign(TextAlign.Center)
      .fontColor(Color.Black)
      .font({ size: 25, weight: 10, style: FontStyle.Italic })
      .border({ width: 3, color: Color.Black, radius: 25, style: BorderStyle.Dashed })

  }
}
分享
微博
QQ
微信
回复
2025-01-10 10:29:53
相关问题
自定义组件如何添加图片?
3776浏览 • 1回复 待解决
HarmonyOS 键盘顶部添加自定义组件
1340浏览 • 1回复 待解决
HarmonyOS UI组件自定义点击范围
1580浏览 • 1回复 待解决
HarmonyOS 地图自定义marker
1076浏览 • 1回复 待解决
Tabs组件自定义导航栏UI问题
1880浏览 • 1回复 待解决
HarmonyOS 地图自定义气泡功能
888浏览 • 1回复 待解决
HarmonyOS 地图自定义弹窗消息窗
1053浏览 • 1回复 待解决
HarmonyOS 如何添加自定义的资源路径
960浏览 • 1回复 待解决
HarmonyOS 地图自定义信息框不生效
957浏览 • 1回复 待解决
Ark UI是否如何使用自定义字体
4094浏览 • 1回复 待解决
如何自定义函数中创建一个UI组件
2869浏览 • 1回复 待解决
HarmonyOS 定义自定义组件
1467浏览 • 1回复 待解决