开源地址:https://github.com/lovebing/react-native-baidu-map
今天在React native中导入百度地图组件遇到过许多坑,特此写一篇博客记录踩过的坑...
1、Install 安装
npm install react-native-baidu-map --save
2、在settings.gradle中添加以下内容
include ':app'
include ':react-native-baidu-map'
project(':react-native-baidu-map').projectDir = new File(settingsDir, '../node_modules/react-native-baidu-map/android')
3、在build.gradle中添加:
compile project(':react-native-baidu-map')
如下:
4、修改MainApplication.java 文件
添加:new BaiduMapPackage(getApplicationContext())
除此之外,别忘了将包导进来:不过一般都会自动导进来。
MainApplication
import org.lovebing.reactnative.baidumap.BaiduMapPackage;
5、修