Skip to content

使用Marker自定义图标时报错 #849

@wulianyougithub

Description

@wulianyougithub

react-native-amap3d版本:3.2.4
react-native版本:0.78.1
平台:android

错误代码:

 <Marker
        position={{
          latitude: item.latitude,
          longitude: item.longitude,
        }}
        ref={markerRef}
      >
        <View style={styles.markerContainer}>
          <ImageBackground
            source={require('../../assets/images/location/pop.png')}
            style={styles.markerPopup}
            resizeMode="contain"
            onLoadEnd={() => {
              // 图片加载完成后延迟更新
              setTimeout(() => {
                markerRef.current?.update();
              }, 200);
            }}
          >
            <View style={styles.popupContent}>
              <Image
                source={item.avatar?item.avatar:require('../../assets/images/complete/man.png')}
                style={styles.avatarImage}
                onLoadEnd={() => {
                  // 图片加载完成后延迟更新
                  setTimeout(() => {
                    markerRef.current?.update();
                  }, 200);
                }}
              />
              <Text style={styles.nameText}>{item.name}</Text>
              <Image
                source={require('../../assets/images/location/pop_right.png')}
                style={styles.rightImage}
                onLoadEnd={() => {
                  // 图片加载完成后延迟更新
                  setTimeout(() => {
                    markerRef.current?.update();
                  }, 200);
                }}
              />
            </View>
          </ImageBackground>
          <Image
            source={require('../../assets/images/location/marker.png')}
            style={{ width: 45, height: 34.54 }}
            onLoadEnd={() => {
              // 图片加载完成后延迟更新
              setTimeout(() => {
                markerRef.current?.update();
              }, 200);
            }}
          />
        </View>
      </Marker>

具体错误为:

Image

使用自定义图标,就算不包含异步加载的组件,只是Text组件也是会报这个问题,我该如何解决这个问题!!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions