我在地图初始化中设置了自定义样式网址。喜欢 :
<Mapbox.MapView
styleURL="asset://mystyle.json"
logoEnabled={false}
attributionEnabled={false}
ref={(e) => { this.oMap = e }}
animate={true}
zoomLevel={6}
centerCoordinate={[54.0, 24.0]}
style={{ flex: 1 }}
showUserLocation={true}>
</Mapbox.MapView>
Run Code Online (Sandbox Code Playgroud)
在mystyle.json中,我有两个基本映射,如下所示:
{
"id": "Satellite",
"type": "raster",
"source": "Satellite",
"layout": {
"visibility": "visible"
},
"paint": {
"raster-opacity": 1
}
},
{
"id": "Satellite2",
"type": "raster",
"source": "Satellite",
"layout": {
"visibility": "none"
},
"paint": {
"raster-opacity": 1
}
}
Run Code Online (Sandbox Code Playgroud)
卫星默认可见。
如何在运行时将Satellite属性的可见性设置为None,将Satellite2可见性设置为可见?
Mapbox gl:
"@mapbox/react-native-mapbox-gl": "^6.1.3"
Run Code Online (Sandbox Code Playgroud)
反应本机:
"react-native": "0.58.9",
Run Code Online (Sandbox Code Playgroud)