我正在使用react-native-mapbox-gl在我的react应用程序中显示地图,在页面加载时,它应该像google地图一样显示用户的位置,但它无法显示,而是显示地图的其他一些区域。
有人能帮帮忙吗?
提前谢谢。
以下是代码片段
import { StyleSheet, View } from "react-native";
import MapboxGL from "@react-native-mapbox-gl/maps";
MapboxGL.setAccessToken("<YOUR_ACCESSTOKEN>");
const styles = StyleSheet.create({
page: {
flex: 1,
justifyContent: "center",
alignItems: "center",
backgroundColor: "#F5FCFF"
},
container: {
height: 300,
width: 300,
backgroundColor: "tomato"
},
map: {
flex: 1
}
});
export default class App extends Component {
componentDidMount() {
MapboxGL.setTelemetryEnabled(false);
}
render() {
return (
<View style={styles.page}>
<View style={styles.container}>
<MapboxGL.MapView style={styles.map} />
<MapboxGL.UserLocation />
</View>
</View>
);
}
}发布于 2021-01-10 19:34:56
您可以将MapboxGL.Mapview传递给孩子。
<MapboxGL.MapView style={styles.map}>
<MapboxGL.UserLocation/>
</MapboxGL.MapView>发布于 2020-03-02 15:17:05
https://stackoverflow.com/questions/60484056
复制相似问题