【问题标题】:How can I change the size of a marker in react native maps?如何更改反应原生地图中标记的大小?
【发布时间】:2019-11-22 22:19:34
【问题描述】:

我正在尝试减小地图上标记的大小,因为它太大了。

问题是在这种情况下使用 style = {} 似乎不起作用。

我在这里错过了什么?

   <MapView.Marker
        coordinate={{ latitude: 52.78825, longitude: 13.4324 }}
        title="This should be me"
        description="Some description"
        image={require('../assets/icon.png')}
        style={{width: 26, height: 28}}
      >

【问题讨论】:

    标签: react-native maps android-mapview


    【解决方案1】:

    您可以按照文档here 以这种方式呈现标记:

    <Marker ...>
      <Image
        source={require('../assets/icon.png')}
        style={{width: 26, height: 28}}
        resizeMode="contain"
      />
    </Marker>
    

    【讨论】:

    • 我试过这种方法,它根本不显示图像,而只是默认标记。这就是我最终使用上面代码的原因。
    • @YahirCasas 你能试试我更新的答案吗?这对我有用。
    • 它不起作用 :( 图像看起来和往常一样大。唯一改变的是我现在收到一条警告说“无法激活 KeepAwake”。
    • 它对我有用,但是为了保留正确的坐标,我必须将 resizeMode="center"resizeMethod="resize" 传递给 Image 组件。
    • 这种方法对我有用,但我无法在运行时动态更改标记大小。当我将其设置为大于初始尺寸(例如,第一个 32x32,然后是 64x64)时,标记在底部和右侧被切断。
    猜你喜欢
    • 2020-02-24
    • 2015-12-06
    • 2019-02-28
    • 1970-01-01
    • 2018-12-09
    • 1970-01-01
    • 1970-01-01
    • 2019-11-17
    • 2023-03-29
    相关资源
    最近更新 更多