【发布时间】:2017-01-27 12:03:01
【问题描述】:
我正在尝试让 react-native-maps Marker 显示在我的 Android 设备上(它在 iOS 上工作得非常好)但它给我一个 IndexOutofBoundsException: Invalid index 1, size is 0 error at render time。
http://i.imgur.com/owletnw.png
render() {
const INITIAL_REGION = { latitude: 52.221835, longitude: 21.000896, latitudeDelta: 0.0922, longitudeDelta: 0.0421 };
return (
<MapView ref="map"
showsUserLocation = { true }
loadingEnabled = { true }
showsTraffic = { false }
showsBuildings = { false }
style = { styles.map, {flex: 1} }
initialRegion = { INITIAL_REGION }
>
<View style={{flex: 0.1, flexDirection: 'row', position: 'absolute', justifyContent: 'space-between', backgroundColor: 'transparent'}}>
<Button onPress={() => this.showWithinRadius(5)}>Wszystkie ~5km</Button>
<Button onPress={() => this.showWithinRadius(10)}>Wszystkie ~10km</Button>
<Button onPress={() => this.showWithinRadius(15)}>Wszystkie ~15km</Button>
<Button onPress={() => this.showAllOffers()}>Wszystkie oferty</Button>
</View>
{ console.log(this.state.offerLocation) }
<Marker
coordinate = { {latitude: 52.259216308593, longitude: 21.041564941406} }
title = { this.props.selectedOffer.offer.title }
/>
</MapView>
);
}
知道是什么导致了这种行为吗?我尝试从 MapView 组件中删除 View 块,但这似乎没有帮助。在实际的应用程序中,我计划通过一个似乎在 fitToCoordinates 方法中工作的对象传递坐标。
【问题讨论】:
标签: react-native react-native-android react-native-maps