For AI agents: the complete documentation index is available at /apps-plugin/docs/llms.txt, the full documentation bundle is available at /apps-plugin/docs/llms-full.txt, and this page is available as Markdown at /apps-plugin/docs/templates/map-card.md.

地图卡

MapCard 用于展示路线预估、叫车状态和位置详情,由固定高度地图、可选信息区和操作区组成。地图覆盖物通过 mapProps 配置,卡片统一管理地图尺寸和卡片结构。

示例

import { MapCard } from '@doubao-dev/template';

export default function RideMapCard() {
  return (
    <MapCard
      mapProps={{
        center: { latitude: 39.9087, longitude: 116.3975 },
        scale: 14,
        polyline: [
          {
            id: 'route',
            points: [
              { latitude: 39.9151, longitude: 116.4039 },
              { latitude: 39.9042, longitude: 116.3925 }
            ],
            width: 5
          }
        ]
      }}
      title="预估 29 元"
      metaItems={[{ text: '最高优惠 6 元', tone: 'highlight' }, { text: '已选 4 种车型' }]}
      inlineActions={[
        {
          text: '确认叫车',
          onClick: () => console.log('confirm ride')
        }
      ]}
    />
  );
}

主要 Props

Prop类型必填说明
mapPropsMapCardMapProps是地图配置,不包含 className 和 style
titleTemplateText否信息区标题
showArrowboolean否是否展示标题右侧箭头,默认 true
metaItemsMapCardMetaItem[]否辅助信息,最多展示前 2 项
inlineActionsTemplateCardFooterActionButton[]否信息区右侧操作,最多展示前 2 个
footerTemplateCardFooterProps否底部主、次操作按钮
onClick(event) => void否点击卡片根节点时触发

MapCardMetaItem 包含 key、text 和 tone。text 是必填的辅助信息;tone 支持默认灰色 default 和豆包蓝 highlight。

使用说明

  • 地图区域高度固定为 168px。mapProps 透传地图能力,但卡片统一管理地图的 className、style 和尺寸。
  • 地图覆盖物通过 mapProps.children 传入,例如 MapMarker;不要使用卡片 children。
  • ref 直接绑定到内部 Map,类型为 MapRef,可调用 getCenter、setCenter 等实例方法。
  • title 使用单行 Title Primitive,showArrow 默认 true。
  • metaItems 会过滤空文案并最多展示前 2 项;多项之间由模板渲染分隔点。
  • inlineActions 单按钮按主按钮展示;双按钮依次按次按钮、主按钮展示。
  • 信息区和 footer 都是可选结构,可以分别单独展示或组合展示。
  • 地图左上角的应用插件标题由客户端 titleType 控制,MapCard 不重复渲染来源标题。