MapMarker 没有原生道具的 propTypes 'AIRMapMarker.testID'

MapMarker has no propTypes for native prop 'AIRMapMarker.testID'

我正在使用 react-native-maps (v-0.16.4) 它适用于 ios 但 MapView.marker 不适用于 android

完整的错误陈述是-

MapMarker 没有原生类型字符串的原生属性 'AIRMapMarker.testID' 的 propTypes。如果您没有自己更改此道具,这通常意味着您的本机代码版本和 Javascript 代码不同步。更新两者应该会使这个错误消失。

this is image for error description

我的地图文件是-

<MapView
           provider={Platform.OS === 'ios' ? PROVIDER_DEFAULT :  PROVIDER_GOOGLE }
            style={{
              left: 0,
              right: 0,
              top: 0,
              bottom: 0,
              position: 'absolute'
            }}
          region={{
            latitude:128.569184,
            longitude: 73.765760,
            latitudeDelta: 0.00942,
            longitudeDelta: 0.0843
          }}
          ref={map => { this.map = map }}
        >
          <MapView.Marker
          map = {this.map}
            coordinate={{
              latitude: 128.568806,
              longitude: 73.765210
            }}
            image={"http://pokeapi.co/media/sprites/pokemon/1.png"}
            title='ETHEL and Friends'
            >
            </MapView.Marker>
        </MapView>

我检查了 docs 中的 MapView.Marker,发现您的 image 属性值错误。您需要将其设置为本地ImageSource类型。

来自文档:

image (ImageSource)

A custom image to be used as the marker's icon. Only local image resources are allowed to be used.

例子

<MapView ref={map => { this.map = map; }}>
  <MapView.Marker
    map={this.map}
    coordinate={{latitude: 128.568806, longitude: 73.765210}}
    image={require('media/sprites/pokemon/1.png')}
    title='ETHEL and Friends'
  >
  </MapView.Marker>
</MapView>