我正在寻找一种在我的反应本机应用程序中使用 OpenStreetMap 数据的方法。在我最近的研究中,我发现了MapLibre,它是基于 MapBox GL 旧版本的免费选项。我面临的问题是,除了@react-native-mapbox-gl/maps之外,我找不到任何插件可以在 React Native 中使用它。因此,在他们的文档中说:“我们现在也支持 Mapbox SDK 的 MapLibre 风格”,但他们提出的示例如下:
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 {
render() {
return (
<View style={styles.page}>
<View style={styles.container}>
<MapboxGL.MapView style={styles.map} />
</View>
</View> …Run Code Online (Sandbox Code Playgroud) javascript openstreetmap react-native mapbox-gl-js maplibre-gl