使用谷歌地图 API 时无法将自定义图像添加到我的 Pin 图?

问题描述 投票:0回答:1

我需要向我的 Pin 图添加自定义图像,但 Pin 元素不排除图像。 我还需要能够根据某些标准在图像之间切换,因此我会得到混合的 pin 图像。

尝试过这个:

`

        <Image src="/pin-icon.png" alt="Pin Icon" layout="fill" objectFit="contain"/>        
    
</Pin>

`

但什么也没得到。 如果有人可以帮我找到解决方案。

javascript
1个回答
0
投票

这里的问题看起来像是您正在尝试使用 Pin comp 中不直接支持的组件。相反,请尝试使用 HTML img 标签或任何其他支持的方法

尝试使用这样的东西

<Pin background={'#FBBC04'} glyphColor={'#575'} borderColor={'#000'}>
  <div style={{ position: 'relative', width: '100%', height: '100%' }}>
    <img
      src="/pin-icon.png"
      alt="Pin Icon"
      style={{
        width: '100%',
        height: '100%',
        objectFit: 'contain',
      }}
    />
  </div>
</Pin>

© www.soinside.com 2019 - 2024. All rights reserved.