gpt4 book ai didi

javascript - 如何在 React Native 中集成 Open Street map ?

转载 作者:行者123 更新时间:2023-11-30 19:01:07 24 4
gpt4 key购买 nike

我想使用 Open Street Map 而不是 Google map ,所以我用react-native-maps-osmdroid处理它

但是我在 View 中看不到任何 map ,所以我应该在设置时添加一些东西吗?

"I don't have Google key cuz react-native-maps require it so that's reason to use react-native-maps-osmdroid"

截图

screenshot

代码

import React, {Component} from 'react';
import {Text, View} from 'react-native';
import MapView, {Marker} from 'react-native-maps-osmdroid';

class MapTest extends Component {
render() {
return (
<View>
<MapView
style={{flex: 1}}
initialRegion={{
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}}>
<Marker
title="Home"
color="#f00"
coordinate={{
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}}
/>
</MapView>
</View>
);
}
}

export default MapTest;

最佳答案

您仍然需要使用 react-native-maps-osmdroid 的 API key .

The actual map implementation depends on the platform. On Android, one has to use >Google Maps, which in turn requires you to obtain an API key for the Android SDK.

您可以免费获得 API key 。关注this tutorial即可

关于javascript - 如何在 React Native 中集成 Open Street map ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59504789/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com