小编dav*_*wim的帖子

图像不会显示在 PointAnnotations 上 - React Native MapboxGL

我正在从 react-native-maps 过渡到 rnmapbox,但在让任何图像显示在标记上时遇到问题。我正在渲染图像标记和某些标记的附加徽章。此问题仅在使用图像时出现,CSS 标记工作正常。

左边的图像是我使用 React Native Maps 时的预期结果,右边的图像是使用 MapboxGL 的结果。

下面是我的代码片段:

<MapboxGL.PointAnnotation
  key={"vehicle-" + vehicle._id}
  id={"vehicle-" + vehicle._id}
  coordinate={[vehicle.longitude, vehicle.latitude]}
  anchor={
    vehicle.status !== "riding" &&
    vehicle.status !== "adminCollected" &&
    vehicle.status !== "warehoused"
      ? { x: 0.5, y: 1 }
      : { x: 0.5, y: 0.5 }
  }
  onSelected={() => centerOnMarker(vehicle)}
>
  <View style={{ height: 75, width: 75 }}> {/* sized used for testing */}
    {vehicle.status === "available" ? (
      vehicle.batteryPercentage > 65 ? (
        <Image
          source={require("../../assets/scooter-pins/green-full.png")}
          style={{ height: …
Run Code Online (Sandbox Code Playgroud)

javascript mapbox react-native react-native-mapbox-gl

1
推荐指数
1
解决办法
1377
查看次数