Skip to content

Commit

Permalink
Merge pull request #365 from dapetcu21/master
Browse files Browse the repository at this point in the history
Re-design API more into the React sprit. Unify Android and iOS APIs
  • Loading branch information
tmcw authored Jul 22, 2016
2 parents 4c76d40 + ee388a9 commit 117c756
Show file tree
Hide file tree
Showing 29 changed files with 3,891 additions and 2,444 deletions.
438 changes: 438 additions & 0 deletions API.md

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#v5.0.0

* Major breaking API changes. See the [API documentation](/API.md) for details.
* Unifies Android & iOS APIs.
* Adds support for telemetry opt-out.
* Adds offline maps support for Android.

#v4.1.1

* [Android] Fixes `Scrollable` error
Expand Down
105 changes: 0 additions & 105 deletions android/API.md

This file was deleted.

2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ repositories {

dependencies {
compile 'com.facebook.react:react-native:0.19.+'
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:3.2.0@aar') {
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:4.1.1@aar') {
transitive = true
}
}
145 changes: 0 additions & 145 deletions android/example.js

This file was deleted.

87 changes: 29 additions & 58 deletions android/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@ Run with ```--ignore-scripts``` to disable ios startup script
```shell
npm install --save react-native-mapbox-gl --ignore-scripts
```
#### Step 2 - Update Gradle Settings

#### Step 2 - Use with Gradle

##### Option A - With [rnpm](https://github.com/rnpm/rnpm)

```shell
rnpm link
```

##### Option B - Manually

Edit the following files:

```gradle
// file: android/settings.gradle
Expand All @@ -15,8 +26,6 @@ include ':reactnativemapboxgl'
project(':reactnativemapboxgl').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-mapbox-gl/android')
```

#### Step 3 - Update app Gradle Build

```gradle
// file: android/app/build.gradle
...
Expand All @@ -27,45 +36,11 @@ dependencies {
}
```

#### Step 4 - Register React Package

##### react-native < v0.18.0

```java
...
// file: android/app/src/main/java/com/yourcompany/yourapp/MainActivity.java
import com.mapbox.reactnativemapboxgl.ReactNativeMapboxGLPackage; // <-- import
...

public class MainActivity extends FragmentActivity implements DefaultHardwareBackBtnHandler {

private ReactInstanceManager mReactInstanceManager;
private ReactRootView mReactRootView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mReactRootView = new ReactRootView(this);
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
.addPackage(new ReactNativeMapboxGLPackage()) // <-- Register package here
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
mReactRootView.startReactApplication(mReactInstanceManager, "AwesomeProject", null);
setContentView(mReactRootView);
}
...
```

##### react-native >= v0.18.0, <0.29.0

```java
import com.mapbox.reactnativemapboxgl.ReactNativeMapboxGLPackage; // <-- import
...
/**
/**
* A list of packages used by the app. If the app uses additional views
* or modules besides the default ones, add more packages here.
*/
Expand All @@ -77,25 +52,21 @@ import com.mapbox.reactnativemapboxgl.ReactNativeMapboxGLPackage; // <-- import
}
```

##### react-native >= v0.29.0
#### Step 3 - Add Mapbox to AndroidManifest.xml

```java
// file: android/app/src/main/java/com/<YOURAPP>/MainApplication.java
...
import com.mapbox.reactnativemapboxgl.ReactNativeMapboxGLPackage; // <-- import
...
public class MainApplication extends Application implements ReactApplication {
...
/**
* 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<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new ReactNativeMapboxGLPackage()); // <-- Register package here
}
Add the following permissions to your `AndroidManifest.xml`:

```xml
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
```

Also, add the Mapbox analytics service:

```xml
<service android:name="com.mapbox.mapboxsdk.telemetry.TelemetryService"/>
```

#### Step 5 - Add to project, [see example](./example.js)
#### Step 4 - Add to project, [see example](../example.js)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.mapbox.reactnativemapboxgl;

import com.mapbox.mapboxsdk.annotations.Annotation;
import com.mapbox.mapboxsdk.maps.MapboxMap;

public interface RNMGLAnnotationOptions {
public abstract Annotation addToMap(MapboxMap map);
}
Loading

0 comments on commit 117c756

Please sign in to comment.