Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/laoqiu/react-native-amap

react native amap module for android
https://github.com/laoqiu/react-native-amap

Last synced: 6 days ago
JSON representation

react native amap module for android

Awesome Lists containing this project

README

        

# React Native AMap
A React Native component for building maps with the [AMap Android SDK](http://lbs.amap.com/api/android-sdk/summary/).

## Example
```
...
import MapView from 'react-native-amap';

class example extends Component {
render() {
return (


Welcome to React Native!



);
}
}
...
```
![image](example/example.png)

## Install

### Step 1 - NPM install

```
npm install react-native-amap --save
```

### Step 2 - Update Gradle Settings

```
// file: android/settings.gradle
...

include ':reactamap'
project(':reactamap').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-amap')
```

### Step 3 - Update app Gradle Build

```
// file: android/app/build.gradle
...

dependencies {
...
compile project(':reactamap')
}
```

### Step 4 - Register React Package

#### react-native >= v0.18.0
```
import com.laoqiu.amap.AMapReactPackage;
...
/**
* A list of packages used by the app. If the app uses additional views
* or modules besides the default ones, add more packages here.
*/
@Override
protected List getPackages() {
return Arrays.asList(
new MainReactPackage(),
new AMapReactPackage()); // <-- Register package here
}
...
```
#### react-native < v0.18.0
```
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mReactRootView = new ReactRootView(this);
mReactInstanceManager = ReactInstanceManager.builder()
...
.addPackage(new AMapReactPackage()) // <-- Register package here
...
.build();
...
```
### Step 5 - Add map permission and api key

```
// file: android/app/src/main/AndroidManifest.xml
...












...
```