Ale*_*der 0 react-native react-native-android react-native-maps
我正在尝试让 react-native-maps 标记显示在我的 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>
);
}
Run Code Online (Sandbox Code Playgroud)
知道什么可能导致这种行为吗?我试过从 MapView 组件中删除 View 块,但这似乎没有帮助。在实际的应用程序中,我计划通过一个似乎在 fitToCoordinates 方法中工作的对象传递坐标。
小智 5
这个问题没有给出解决方案,但它帮助我理解并修复了我的问题。我不认为这View是问题,而是组件呈现的顺序。在 Android 上,渲染顺序似乎很重要。所以,渲染Markers为第一个孩子MapView为我修复了它。
这里也提到了:https : //github.com/react-community/react-native-maps/issues/291
希望我能帮上忙!
| 归档时间: |
|
| 查看次数: |
1659 次 |
| 最近记录: |