小编Ben*_*ant的帖子

React Native - MapView - 带有自定义图像的注释

我正在编写一个使用MapView组件的本机应用程序.我想要自定义图像的注释.MapView的React Native Docs就是这么说的.

var CustomPinImageMapViewExample = React.createClass({

  getInitialState(): CustomPinImageMapViewExampleState {
    return {
      isFirstLoad: true,
    };
  },

  render() {
    if (this.state.isFirstLoad) {
      var onRegionChangeComplete = (region) => {
        this.setState({
          isFirstLoad: false,
          annotations: [{
            longitude: region.longitude,
            latitude: region.latitude,
            title: 'Thumbs Up!',
            image: require('image!uie_thumb_big'),
          }],
        });
      };
    }

    return (
      <MapView
        style={styles.map}
        onRegionChangeComplete={onRegionChangeComplete}
        region={this.state.mapRegion}
        annotations={this.state.annotations}
      />
    );
  },

});
Run Code Online (Sandbox Code Playgroud)

并告诉我注释具有image应该设置为Image.propTypes.source的属性.

annotations [{latitude: number, longitude: number, animateDrop: bool,
title: string, subtitle: string, hasLeftCallout: bool, hasRightCallout:
bool, onLeftCalloutPress: function, onRightCalloutPress: function, …
Run Code Online (Sandbox Code Playgroud)

react-native

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

标签 统计

react-native ×1