React native 设置React本机MapView触摸事件处理程序
Facebook的地图视图只是用来显示注释(地图标记)吗?似乎没有办法为触笔事件添加事件处理程序。我必须使用类似于的东西吗?你试过使用AnnotationPress吗React native 设置React本机MapView触摸事件处理程序,react-native,React Native,Facebook的地图视图只是用来显示注释(地图标记)吗?似乎没有办法为触笔事件添加事件处理程序。我必须使用类似于的东西吗?你试过使用AnnotationPress吗 您试过使用AnnotationPress吗 听说我的代码工作正常 constructor(props) { super(props); this.state = { region : {latitude: LATITUDE,
您试过使用AnnotationPress吗
听说我的代码工作正常
constructor(props) {
super(props);
this.state = {
region : {latitude: LATITUDE,
longitude: LONGITUDE,
latitudeDelta: LATITUDE_DELTA,
longitudeDelta: LONGITUDE_DELTA,},
annotations : [],
};
for (var i = 0; i < this.props.list.length; i++) {
this.state.annotations[i] = {latitude:parseFloat(this.props.list[i].latitude),
longitude: parseFloat(this.props.list[i].longitude),
animateDrop: true,
/*title: this.props.list[i].name,
subtitle: this.props.list[i].address,*/
image : require('../images/icons/pharmacy-map-normal.png'),
id : i.toString()}
};
}
render() {
return (
<View>
<MapView
style={styles.map}
showsUserLocation={true}
region={this.state.region}
onAnnotationPress={this.onAnnotationPress}
annotations={this.state.annotations}>
</MapView>
</View>
);
}
onAnnotationPress =(annotation) =>{
alert(annotation.id)
}
构造函数(道具){
超级(道具);
此.state={
地区:{纬度:纬度,
经度:经度,
纬度三角洲:纬度三角洲,
经度三角洲,
注释:[],
};
for(var i=0;i{
警报(annotation.id)
}
听说我的代码很好用
constructor(props) {
super(props);
this.state = {
region : {latitude: LATITUDE,
longitude: LONGITUDE,
latitudeDelta: LATITUDE_DELTA,
longitudeDelta: LONGITUDE_DELTA,},
annotations : [],
};
for (var i = 0; i < this.props.list.length; i++) {
this.state.annotations[i] = {latitude:parseFloat(this.props.list[i].latitude),
longitude: parseFloat(this.props.list[i].longitude),
animateDrop: true,
/*title: this.props.list[i].name,
subtitle: this.props.list[i].address,*/
image : require('../images/icons/pharmacy-map-normal.png'),
id : i.toString()}
};
}
render() {
return (
<View>
<MapView
style={styles.map}
showsUserLocation={true}
region={this.state.region}
onAnnotationPress={this.onAnnotationPress}
annotations={this.state.annotations}>
</MapView>
</View>
);
}
onAnnotationPress =(annotation) =>{
alert(annotation.id)
}
构造函数(道具){
超级(道具);
此.state={
地区:{纬度:纬度,
经度:经度,
纬度三角洲:纬度三角洲,
经度三角洲,
注释:[],
};
for(var i=0;i{
警报(annotation.id)
}
我在MapView上尝试了onAnnotationPress,但没有任何效果<代码>和处理它的函数onAnnotationPress(id){console.log('onAnnotationPress yoooo'+id);},
我在MapView上尝试了onAnnotationPress,但它没有做任何事情<代码>和处理它的函数onAnnotationPress(id){console.log('onAnnotationPress yoooo'+id);},
我在MapView上尝试了onAnnotationPress,但它没有做任何事情<代码>和处理它的函数onAnnotationPress(id){console.log('onAnnotationPress yoooo'+id);},