TouchableOpacity onPress在react-native-map中的CallOut内部不起作用

时间:2019-12-19 09:52:54

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

我正在使用react-native-map,并希望在标注视图中创建不同的按钮,但是onPress在其中不起作用。我在标记内使用标注。如果有解决此问题的解决方法,请告诉我。

这是我的代码:

export default class MapTest extends Component {
      constructor(props) {
        super(props);
        this.state = {
      }

      render() {
        return (
          <View style={{ flex: 1 }}>
            <MapView
              style={styles.map}
              region={{
                latitude: this.state.lat,
                longitude: this.state.long,
                latitudeDelta: 0.0922,
                longitudeDelta: 0.0421,
              }}
              showsUserLocation={true}
            >
              <Marker
                ref={ref => { this.mark = ref; }}
                coordinate={{
                  latitude: this.state.lat,
                  longitude: this.state.long
                }}
                title={this.state.formatted_address}
                description='View Details'

              >
                <Callout>
                <View style={{marginTop: 15, flex: 1}}>
                   <Text style={{fontWeight: "bold"}}>{this.state.Title}</Text>
                    </View>
                    <TouchableOpacity style={{marginTop: 15, flex: 1}} onPress={() => {console.log('this is not working!')}}>
                   <Text style={{fontWeight: "bold"}}>Details</Text>
                    </TouchableOpacity>
                </Callout>
              </Marker>
            </MapView>
          </View>
        );
      }
    }

0 个答案:

没有答案