Skip to content

Commit

Permalink
Merge tag '7.0.4' into release/7.0.4-robin
Browse files Browse the repository at this point in the history
  • Loading branch information
jutaz committed Sep 20, 2019
2 parents 18d6211 + 15cd5d3 commit d67d706
Show file tree
Hide file tree
Showing 111 changed files with 1,735 additions and 820 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ module.exports = {
"plugin:flowtype/recommended"
],
"rules": {
"react/no-deprecated": "error",
"react/no-deprecated": "warn",
"react/no-string-refs": "warn",
"import/named": [2],
"import/no-named-default": [0],
"import/order": ["error", { "groups": ["builtin", "external", "parent", "sibling", "index"], "newlines-between": "always" }],
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ reactnativemapboxgl.iml
coverage
.project
*.core.prefs
*.iml

# Buck
.buckd
Expand All @@ -58,3 +59,6 @@ buck-out
/ReactAndroid/src/main/jni/prebuilt/lib/x86/
/ReactAndroid/src/main/gen

# VSCode
.vscode/
.classpath
34 changes: 24 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

### Breaking changes:

* iOS mapbox libraries updated to [5.0.0](https://github.com/mapbox/mapbox-gl-native/releases/tag/ios-v5.0.0) android libraries updated to [8.0.0](https://github.com/mapbox/mapbox-gl-native/releases/tag/android-v8.0.0)
* `StyleSheet.create` removed.
Mapbox styles are now just a map no need for `StyleSheet.create`.
* iOS mapbox libraries updated to [5.2.0](https://github.com/mapbox/mapbox-gl-native/releases/tag/ios-v5.2.0) android libraries updated to [8.2.1](https://github.com/mapbox/mapbox-gl-native/releases/tag/android-v8.2.1)
* `StyleSheet.create` removed.
Mapbox styles are now just a map no need for `StyleSheet.create`.
`StylesSheet.identity` also removed, use expressions array instead:
```jsx
mapboxStyle=MapboxGL.Stylesheet.create({..., fillColor: MapboxGL.Stylesheet.identity('color') ...})
Expand All @@ -14,7 +14,7 @@ Mapbox styles are now just a map no need for `StyleSheet.create`.
<FillLayer style={mapboxStyle}... />
</MapView>
```

is now:
```jsx
mapboxStyle={..., fillColor: ['get', 'color'] ...}
Expand All @@ -37,9 +37,9 @@ Mapbox styles are now just a map no need for `StyleSheet.create`.
...
</MapView>
```

is now:

```jsx
<MapView
...
Expand All @@ -60,9 +60,9 @@ Mapbox styles are now just a map no need for `StyleSheet.create`.
...
</MapView>
```

is now:

```jsx
<MapView
...
Expand All @@ -72,10 +72,24 @@ Mapbox styles are now just a map no need for `StyleSheet.create`.
followUserMode="normal"
/>
</MapView>
```
```
The following properties were changed:
* MapView#userTrackingMode is now Camera#followUserMode and Camera#followUserLocation
* followUserMode is now a string with ('normal','compass','course'), and UserTrackingModes enum is deprecated
* MapView#onUserTrackingModeChange is now Camera#onUserTrackingModeChange and payload contains followUserMode and followUserLocation.
* MapView#onUserTrackingModeChange is now Camera#onUserTrackingModeChange and payload contains followUserMode and followUserLocation.

* ShapeSource#images was depreacted, use Images#images instead.
```jsx
<MapView
...
>
...
<Images images={{pin, dot}} />
...
<ShapeSource ... >
<SymbolLayer ...>
</ShapeSource>
</MapView>
```

* TODO document all changes
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,10 @@ commit the changes and push them to a fork for creating a pull request.

1. If you add a feature, make sure you add it to the documentation
1. If you add an objective-c or java method, make sure you update the declaration file: `index.d.ts`.


## Documentation

1. Documentation is auto-generated from code blocks and comments. To generate documentation:
1. `npm install -g documentation` to install documentation generator
1. `npm run generate` to generate updated documentation
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ npm install @react-native-mapbox-gl/maps --save
* [OfflineManager](/docs/OfflineManager.md)
* [SnapshotManager](/docs/snapshotManager.md)

### Misc
* [CustomHttpHeaders](/docs/CustomHttpHeaders.md)


## Expo Support
We have a feature request open with Expo if you want to see it get in show your support https://expo.canny.io/feature-requests/p/add-mapbox-gl-support

Expand Down
3 changes: 3 additions & 0 deletions __tests__/modules/snapshot/SnapshotOptions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('SnapshotOptions', () => {
height: 50.0,
writeToDisk: false,
centerCoordinate: JSON.stringify(makePoint(centerCoordinate)),
withLogo: true,
});
});

Expand All @@ -37,6 +38,7 @@ describe('SnapshotOptions', () => {
width: 314,
height: 600,
writeToDisk: true,
withLogo: true,
styleURL: NativeModules.MGLModule.StyleURL.Dark,
};

Expand All @@ -56,6 +58,7 @@ describe('SnapshotOptions', () => {
height: 600,
styleURL: NativeModules.MGLModule.StyleURL.Light,
writeToDisk: false,
withLogo: true,
};

const geoJSONBounds = JSON.stringify(
Expand Down
34 changes: 34 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven { url "https://jitpack.io" }
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
11 changes: 7 additions & 4 deletions android/install.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Android Installation

## If you are using autolinking feature introduced in React-Native `0.60.0` you can skip `react-native link react-native-mapbox-gl` command and just follow first paragraph

`react-native link` should get you almost there,
however we need to add some additional lines to `build.gradle`.


## `android/build.gradle`
## 1. `android/build.gradle`
We need to add an additional repository in order to get our dependencies.

* `https://jitpack.io`
Expand Down Expand Up @@ -42,7 +45,7 @@ however it never hurts to make sure it actually did what it was supposed to
---


## `android/app/build.gradle`
## 2. `android/app/build.gradle`

Add project under `dependencies`

Expand All @@ -60,7 +63,7 @@ You can set the Support Library version or the okhttp version if you use other m
* `okhttpVersion "3.12.1"`


## `android/app/settings.gradle`
## 3. `android/app/settings.gradle`

Include project, so gradle knows where to find the project

Expand All @@ -73,7 +76,7 @@ rootProject.name = <YOUR_PROJECT_NAME>
include ':app'¬
```

## `android/app/src/main/java/com/PROJECT_NAME/MainApplication.java`
## 4. `android/app/src/main/java/com/PROJECT_NAME/MainApplication.java`

We need to register our package

Expand Down
9 changes: 5 additions & 4 deletions android/rctmgl/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

// React Native
compileOnly "com.facebook.react:react-native:+"
implementation "com.facebook.react:react-native:+"

// Mapbox SDK

implementation 'com.mapbox.mapboxsdk:mapbox-sdk-services:4.8.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:8.0.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:8.2.1'

// Dependencies
implementation "com.android.support:support-vector-drawable:${safeExtGet('supportLibVersion', '28.0.0')}"
Expand All @@ -41,7 +41,8 @@ dependencies {
implementation "com.squareup.okhttp3:okhttp:${safeExtGet('okhttpVersion', '3.12.1')}"

// Mapbox plugins
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-localization-v7:0.9.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-markerview-v7:0.2.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-gestures:0.5.1'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-localization-v8:0.10.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-markerview-v8:0.3.0'
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-turf:4.8.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@

public class AbstractEvent extends Event<AbstractEvent> {
private String mEventName;
private final boolean mCanCoalesce;
private WritableMap mEvent;

public AbstractEvent(int viewId, String eventName, @Nullable WritableMap event) {
public AbstractEvent(int viewId, String eventName, boolean canCoalesce, @Nullable WritableMap event) {
super(viewId);
mEventName = eventName;
mCanCoalesce = canCoalesce;
mEvent = event;
}

Expand All @@ -25,4 +27,9 @@ public String getEventName() {
public void dispatch(RCTEventEmitter rctEventEmitter) {
rctEventEmitter.receiveEvent(getViewTag(), getEventName(), mEvent);
}

@Override
public boolean canCoalesce() {
return mCanCoalesce;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void handleEvent(IEvent event) {
}

mRateLimitedEvents.put(eventCacheKey, System.currentTimeMillis());
mEventDispatcher.dispatchEvent(new AbstractEvent(event.getID(), event.getKey(), event.toJSON()));
mEventDispatcher.dispatchEvent(new AbstractEvent(event.getID(), event.getKey(), event.canCoalesce(), event.toJSON()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

public class RCTMGLCalloutManager extends ViewGroupManager<RCTMGLCallout> {
public static final String REACT_CLASS = RCTMGLCallout.class.getSimpleName();
public static final String REACT_CLASS = "RCTMGLCallout";

@Override
public String getName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

public class RCTMGLPointAnnotationManager extends AbstractEventEmitter<RCTMGLPointAnnotation> {
public static final String REACT_CLASS = RCTMGLPointAnnotation.class.getSimpleName();
public static final String REACT_CLASS = "RCTMGLPointAnnotation";

public RCTMGLPointAnnotationManager(ReactApplicationContext reactApplicationContext) {
super(reactApplicationContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ public class CameraStop {
private int mBoundsPaddingLeft = 0;
private int mBoundsPaddingRight = 0;
private int mBoundsPaddingBottom = 0;
private int mBooundsPaddingTop = 0;
private int mBoundsPaddingTop = 0;

private int mMode = CameraMode.EASE;
private int mDuration = 2000;
private MapboxMap.CancelableCallback mCallback;

public CameraStop() {}
public CameraStop() {
}

public void setBearing(double bearing) {
mBearing = bearing;
Expand Down Expand Up @@ -66,7 +67,7 @@ public void setBounds(LatLngBounds bounds, int paddingLeft, int paddingRight, in
mBounds = bounds;
mBoundsPaddingLeft = paddingLeft;
mBoundsPaddingRight = paddingRight;
mBooundsPaddingTop = paddingTop;
mBoundsPaddingTop = paddingTop;
mBoundsPaddingBottom = paddingBottom;
}

Expand All @@ -91,14 +92,23 @@ public CameraUpdateItem toCameraUpdate(MapboxMap map) {
} else if (mBounds != null) {
double tilt = mTilt != null ? mTilt : currentCamera.tilt;
double bearing = mBearing != null ? mBearing : currentCamera.bearing;
int[] cameraPadding = {mBoundsPaddingLeft, mBooundsPaddingTop, mBoundsPaddingRight, mBoundsPaddingBottom};

// Adding map padding to the camera padding which is the same behavior as
// mapbox native does on iOS
int[] mapPadding = map.getPadding();
int paddingLeft = mapPadding[0] + mBoundsPaddingLeft;
int paddingTop = mapPadding[1] + mBoundsPaddingTop;
int paddingRight = mapPadding[2] + mBoundsPaddingRight;
int paddingBottom = mapPadding[3] + mBoundsPaddingBottom;

int[] cameraPadding = {paddingLeft, paddingTop, paddingRight, paddingBottom};
CameraPosition boundsCamera = map.getCameraForLatLngBounds(mBounds, cameraPadding, bearing, tilt);
if (boundsCamera != null) {
builder.target(boundsCamera.target);
builder.zoom(boundsCamera.zoom);
} else {
CameraUpdate update = CameraUpdateFactory.newLatLngBounds(mBounds, mBoundsPaddingLeft,
mBooundsPaddingTop, mBoundsPaddingRight, mBoundsPaddingBottom);
CameraUpdate update = CameraUpdateFactory.newLatLngBounds(mBounds, paddingLeft,
paddingTop, paddingRight, paddingBottom);
return new CameraUpdateItem(map, update, mDuration, mCallback, mMode);
}
}
Expand Down
Loading

0 comments on commit d67d706

Please sign in to comment.