【发布时间】:2018-04-01 17:39:15
【问题描述】:
这是我第一次使用 react-native-maps 在 iOS 上集成 Google 地图。我可以在这个链接中一步一步地在 iOS 上显示谷歌地图:
react-native-maps with Google Map on iOS
然后,出现了新的问题,地图的性能很糟糕(我无法移动地图)。
更新
这是我的代码:
区域将保存在状态:
constructor(props) {
super(props);
this.state = {
region: {
latitude: 10.762622,
longitude: 106.660172,
latitudeDelta: 0.0100,
longitudeDelta: 0.0100,
},
}
}
这是显示地图的代码:
render() {
return (
<View style={styles.container}>
<View
style={styles.mapContainer}>
<MapView
provider={PROVIDER_GOOGLE}
style={styles.map}
region={this.state.region}
showsUserLocation={true}
onRegionChangeComplete={this.onRegionChangeComplete.bind(this)}
>
</MapView>
</View>
</View>
)
}
onRegionChangeComplete(region) {
console.log("region", region);
this.setState({region: region});
}
这些代码在 Android 上运行良好,但我无法在 iOS 上移动地图
如果您有解决此问题的任何想法,请告诉我。提前谢谢!
【问题讨论】:
-
请发布您的代码。另外,请记住模拟器速度较慢。另外,你根本不能拖动,或者它只是很慢?因为如果你想拖动地图,你可能需要启用它。
-
@sfratini:我更新了我的问题。如果您需要任何信息,请告诉我。
-
谢谢。我添加了我的答案。代码没有什么问题,但你可以尝试一下。
标签: javascript ios google-maps google-maps-api-3 react-native