React Native Map Callout Issue,Map Popup Button点击不起作用

时间:2017-12-22 05:20:29

标签: android google-maps react-native android-mapview

我想在地图弹出窗口中单击render() { console.log(TAG + "in render") return ( <View style={{ flex: 1 }}> { (this.state.coords != null) ? <MapView style={styles.map} region={this.state.mapRegion} showsUserLocation={true} followUserLocation={true} onRegionChange={this.onRegionChange.bind(this)} onPress={this.onMapPress.bind(this)}> < MapView.Polyline coordinates = { this.state.coords } strokeWidth = { 4 } /> <MapView.Marker coordinate={ { latitude: this.state.lastLat, longitude: this.state.lastLong, } } > <MapView.Callout tooltip> <View style={styles.bubble}> <View > <Button title='Click Me!' onPress={() => alert('Click')} /> </View> </View> </MapView.Callout> </MapView.Marker> < MapView.Marker coordinate={ { latitude: this.state.destination.latitude, longitude: this.state.destination.longitude, } } /> </MapView> :null } </View> ); } 做出反应原生,所以下面是我的代码

const styles = StyleSheet.create({
bubble: {
    width: 140,
    justifyContent: 'center',
    alignItems: 'center',
    flexDirection: 'row',
    padding:5,
  },
    bubblecontent: {
        padding:5,
    }, 
    bubbleContentTextStyle:{
        fontSize:10,
    },
    iconContainer:{
        height:'50%',
        justifyContent: 'center',
        alignItems: 'center',            
    },
    iconStyle   :{
      height:15,
      weidth:15,
      backgroundColor: 'blue' 
    },
    map: {
        ...StyleSheet.absoluteFillObject,
    },
  });

我的样式表如下

Button

当我在Android上运行上面的代码时,我没有点击MapView.Callout,我放在onPress={() => alert('Click')} 内。

public abstract <T extends BaseViewModel> Class<T> bindViewModel();

我无法在按钮点击时收到警报,不知道如何点击按钮?你的所有建议都很明显。

0 个答案:

没有答案