【问题标题】:React Native Maps - Custom Marker Image Not rendering in Higher Android VersionsReact Native Maps - 自定义标记图像未在更高的 Android 版本中呈现
【发布时间】:2018-12-02 06:17:52
【问题描述】:

图像不显示在标记上。

您好,我正在使用 React-Native 开发一款适用于 Android 的应用,该应用使用 react-native-maps 包。

所有平台都可以正常运行,Android 7.1+ 除外。

标记中包含的所有图像均未显示/加载

在标记组件中有一个名为“image”的道具,它只能用于本地图像。但在我的情况下,我需要渲染远程图像 URL,所以我无法使用这个道具所以我决定使用自定义标记 在我在更高的 Android 版本中测试我的应用程序之前,它运行良好

【问题讨论】:

标签: javascript android google-maps react-native react-native-maps


【解决方案1】:

使用 image prop 定义标记的图像。它适用于 android 7+ 版本

return (
            <MapView.Marker
              key={`marker-${index}`}
              coordinate={{ latitude: Number(latitude), longitude: Number(longitude) }}
              onPress={options.onPress ? () => options.onPress(marker) : false}
              image={icons[marker.type] || icons.default}
              style={styles.marker}
              identifier={marker._id}
            />
        );

【讨论】:

    【解决方案2】:

    它已经解决,因为 react-native-maps 包含修复的新更新。所以现在我可以在地图中渲染动态图像了

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-28
      • 1970-01-01
      • 2023-03-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多