【发布时间】:2019-06-07 10:41:22
【问题描述】:
我的 react-native 地图在 google 上运行,适用于 IOS 和 Android。
有没有办法让 mapType 图层切换器像在 react-native expo 应用程序中启用的谷歌地图应用程序一样?这样用户就可以切换地图类型(标准、卫星、....)
代码的简化版本
constructor(props) {
super(props);
this.state = {
mapRegion: null,
markers: [],
mapType: null
};
}
switchMapType() {
console.log('Changing');
this.state.mapType = 'satellite'
}
render() {
return (
<MapView
provider="google"
mapType={this.state.mapType}
>
<Icon
onPress={this.switchMapType}
/>
</MapView>
);
}
在 state switchMapType() 内部时出现未定义错误。
【问题讨论】:
标签: android ios react-native react-native-maps