首页 文章

React-native-maps v0.20.1 with expo v25.0.0

提问于
浏览
0

我正在使用expo v25.0.0来开发具有反应原生的移动应用程序 . 我的react-native版本是最新版本 . 所以问题是react-native-maps在我的package.json中有react-native@0.51.0和react-native@16.0.0作为依赖,因为我的expo版本是v25.0.0,我有react-native @作为deps,0.52.0和react-native@16.2.0 .

所以运行应用程序我有这个错误:

peer dep missing: react@16.0.0, required by react-native-maps@0.20.1
peer dep missing: react-native@0.51.0, required by react-native-maps@0.20.1

有人可以告诉我应该做什么吗?

我发现这个库:react-native-mapbox-gl,你认为它可以是一个很好的替代品来使用它而不是react-native.maps吗?

谢谢

1 回答

  • 1

    如果要将它们与 Expo 一起使用,则不需要单独引入 react-native-maps . Expo 已经内置了该库 .

    以下是您直接从 Expo 文档导入 MapView 所需的全部内容:

    (他们为 initialRegion 中的lat / lng提供了一些样本坐标,但你可以将它们改为你想要的任何东西 . )

    https://docs.expo.io/versions/latest/sdk/map-view.html

    import React from 'react';
    import { MapView } from 'expo';
    
    export default class App extends React.Component {
      render() {
        return (
          <MapView
            style={{ flex: 1 }}
            initialRegion={{
              latitude: 37.78825,
              longitude: -122.4324,
              latitudeDelta: 0.0922,
              longitudeDelta: 0.0421,
            }}
          />
        );
      }
    }
    

相关问题